Skip to content

Adding new observables to an alert retrospectively is impossible #511

Open
@rolinh

Description

@rolinh

Request Type

Bug

Work Environment

Question Answer
TheHive version 3.0.6

Problem Description

It is impossible to update an alert's list of observables using HTTP PATCH on route /api/alert/:alertId (as described in the documentation).
When trying to do so, the server replies with status code 400 and a message like this one:

{
   "type" : "AttributeCheckingError",
   "tableName" : "alert",
   "errors" : [
      [
         {
            "type" : "UpdateReadOnlyAttributeError",
            "name" : "message",
            "message" : "Attribute message is read-only"
         },
         {
            "message" : "Attribute data is read-only",
            "name" : "data",
            "type" : "UpdateReadOnlyAttributeError"
         },
         {
            "message" : "Attribute tags is read-only",
            "name" : "tags",
            "type" : "UpdateReadOnlyAttributeError"
         },
         {
            "name" : "dataType",
            "message" : "Attribute dataType is read-only",
            "type" : "UpdateReadOnlyAttributeError"
         },
         {
            "name" : "tlp",
            "message" : "Attribute tlp is read-only",
            "type" : "UpdateReadOnlyAttributeError"
         }
      ]
   ]
}

Steps to Reproduce

  1. Use HTTP PATCH on route /api/alert/:alertId with a list of artifacts to update.

Example:

$ cat alert.json
{
    "artifacts": [
        {
            "message": "I like honey",
            "data": "bee",
            "dataType": "other",
            "tlp": 2
        }
    ]
}
$ curl -XPATCH -d @alert.json -H 'Authorization: Bearer <TOKEN>' -H 'Content-Type: application/json' http://localhost:9000/api/alert/<ALERT_ID> | json_pp
{
   "type" : "AttributeCheckingError",
   "errors" : [
      [
         {
            "type" : "UpdateReadOnlyAttributeError",
            "message" : "Attribute message is read-only",
            "name" : "message"
         },
         {
            "message" : "Attribute data is read-only",
            "name" : "data",
            "type" : "UpdateReadOnlyAttributeError"
         },
         {
            "type" : "UpdateReadOnlyAttributeError",
            "name" : "dataType",
            "message" : "Attribute dataType is read-only"
         },
         {
            "type" : "UpdateReadOnlyAttributeError",
            "message" : "Attribute tlp is read-only",
            "name" : "tlp"
         }
      ]
   ],
   "tableName" : "alert"
}

Complementary information

Note that the user requires read+write permissions in order to be allowed to update alerts in the first place. Indeed, the alert role only is not sufficient or you'll be greeted with a 403.

I tried to include all observables (ie including already existing ones) as well as only the new ones to be added and the result is the same in both cases.

Note also that it fails whether the alert already has artifacts or not.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions