Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error code 403 over remote event update using only local tags #1125

Open
minisephirot opened this issue Jan 4, 2024 · 11 comments
Open

Error code 403 over remote event update using only local tags #1125

minisephirot opened this issue Jan 4, 2024 · 11 comments

Comments

@minisephirot
Copy link

minisephirot commented Jan 4, 2024

Context

What: I enrich external organisation events using local tags to ensure that my semantic is not beeing propagated
Why: Those tags are used to pivot on if the IOC should enter a blacklist or not.

Code

How:

        time_window: datetime = oldest_unriched_event_date + timedelta(days = 2) 
        results = self.misp_instance.search(
            controller = "events",
            date_from = oldest_unriched_event_date.strftime("%F"),
            date_to = time_window.strftime("%F"),
            include_correlations = False,
            event_tags = ['!blacklist_tag'],
            org = self.sekoia_uuid,
            deleted = "0",
            pythonify = True,
            metadata = True,
        )
        # Events tagging
        misp_event: MISPEvent
        for counter_ev, misp_event in enumerate(results):
                for tag in [My perfect tag list]:
                    misp_event.add_tag(name = tag, local = True)
                misp_instance.update_event(misp_event)

Sadly I've been using a site admin user to do this stuff while POCing so yeah.. I was able to pretty free in term of perms.

This leads me to using a more appropriated role wich was sync user, thinking that local tags wouldn't be a bother since it was described as "The long awaited feature “local tags” is now finally available. You can create tags locally if you are a member of the given MISP instance’s host organisation, enabling “in-place” tagging for synchronisation and export filtering"

Alas when running the script I get thoses:
ERROR: Something went wrong (403): {'saved': False, 'name': 'Could not edit Event', 'message': 'Could not edit Event', 'url': '/events/edit/9085', 'errors': 'Event could not be saved: The user used to edit the event is not authorised to do so. This can be caused by the user not being of the same organisation as the original creator of the event whilst also not being a site administrator.', 'id': '9085'}

Event 9085 "as is":
image
With local tags added on GUI:
image

There is probably something i've missed while considering local tags: if this is an issue of not beeing in the same organisation why can I add those tags on the same event as a same role user from another organisation on GUI ?

Sorry for the delayed issue by the way I tried to bruteforce my way beforehand to not waste your time if this was just a perm issue..

@Rafiot Rafiot added the S: needs more info Status: needs more information. This issue requires more information from the issue reporter label Jan 4, 2024
@adulau
Copy link
Member

adulau commented Jan 4, 2024

If you have a 403 error, it’s a perm issue and not really an issue with PyMISP.

@iglocska
Copy link
Member

iglocska commented Jan 4, 2024

Based on the provided information, I can safely deduce it's DNS. It's always DNS.

@minisephirot
Copy link
Author

I've completed my issue, sorry for the delay :)

@minisephirot
Copy link
Author

It seems to be related to those issues: MISP/MISP#4691 & MISP/MISP#4925
My user is in host organisation, he tries via API to update an event using only local tags -> 403

@minisephirot
Copy link
Author

minisephirot commented Jan 10, 2024

@adulau

If you have a 403 error, it’s a perm issue and not really an issue with PyMISP.

I thought so too but since MISP allowed me in GUI to edit local tags I thought this was more of a MISP <-> PyMISP interaction

@Rafiot
Does this issue still needs more information ?

EDIT: For now i've found a workaround, the script's user is site admin : that's the only way to bypass this issue.

@Rafiot Rafiot removed the S: needs more info Status: needs more information. This issue requires more information from the issue reporter label Jan 10, 2024
@Rafiot
Copy link
Member

Rafiot commented Jan 10, 2024

@minisephirot no, it doesn't. But it is going to be a MISP API issue, I don't think there is a fix on PyMISP side.

cc @iglocska

@minisephirot
Copy link
Author

@Rafiot Thank you for the feedback.

Should I close this issue and reopen it on MISP's repo or let someone transfer it ?

@Rafiot
Copy link
Member

Rafiot commented Jan 17, 2024

If it works as site admin, it is definitely a perm issue.

Can you check the tag settings and make sure it is not limited to a specific user/org and you're trying to add it from another one?

@minisephirot
Copy link
Author

What do you mean by tag settings ?
I've tried going from:
misp_event.add_tag(name = tag, local = True)
to
attribute.add_tag(name = tag, local = True, exportable = True)
with no significant change in MISP behaviour: is there some settings in MISP to change ?

@Rafiot
Copy link
Member

Rafiot commented Jan 22, 2024

Okay, I looked at the first message again and it's a different issue: the exception happens when you call an update on the MISP event, which would makes sense if you do that against an event that isn't yours.

If I'm not mistaken (please correct me @iglocska), you can attach a local tag to a MISP event that isn't yours if you do something like that: self.misp_instance.tag(event_id, tag_name, local=True). That is assuming a tag with that tag name exists on the MISP instance.

@minisephirot
Copy link
Author

Hello, thank you for the insight.
I thought that calling an update with only tags beeing changed would not trigger a "true" event update like an edition of attributes : that's a good thing to know.
I specificaly avoided misp_instance.(un)tag because it directly called a request http and wanted to bulk tag/untag, I'll try using the method and see if this goes throught !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants