Skip to content

Session Scoped Logs From Workflow Land in Wrong Session When Opening Multiple Files From Project #7857

@utkonos

Description

@utkonos

Version and Platform (required):

  • Binary Ninja Version: 5.3.8844-dev Ultimate, 29d8484
  • OS: macos
  • OS Version: 26.2.0
  • CPU Architecture: arm64

Bug Description:
If you open more than one file simultaneously from a project and are using a custom workflow plugin, even if you scope the logs to the session id retrieved from the binary view, the logs end up in the wrong session.

Steps To Reproduce:

  1. Paste the workflow plugin below into a python file.
  2. Set this workflow in a project.
  3. Open two or more raw files. I suggest four or maybe five because this bug is non-deterministic. The logs may just all land in the right place, but the more files you open simultaneously, the higher the probability that you will be able to observe the bug on the first try.
  4. Look at the logs in all the files. You will see some where two or more sets of logs from another session are marked with the file you're looking at's session id, and if you look at other files, their logs for this workflow plugin are not there.

Expected Behavior:
Scoped logs landing in correct places.

Screenshots:
Here is one file where there are two separate logs coming from this workflow plugin. Note that the session ID appears correct according to other activity from other analysis components, it's just assigning that session ID to logs from another binaryview session (or something like that).

Image

Here are the logs for the file that one of the two in the above screenshot belongs to:

Image

Additional Information:

import json

from binaryninja.log import Logger
from binaryninja.workflow import Workflow, Activity

log = Logger(0, 'reprobug')


def do_action(ctx):
    bv = ctx.view
    log.session_id = bv.file.session_id
    tagged = 0
    for f in bv.functions:
        f.add_tag('Needs Analysis', 'BUGBUG')
        log.log_debug(f'Tagged fuction at: {f.start}')
        tagged += 1
    log.log_info(f'Tagged functions: {tagged}')


wf = Workflow('core.module.metaAnalysis').clone('plugin.module.ReproBug')

activity_name = 'analysis.reprobug'
wf.register_activity(Activity(
    configuration=json.dumps({
        'name': 'analysis.reprobug',
        'title': 'Repro Bug',
        'description': 'Repro Bug.',
        'eligibility': {
            'runOnce': True
        },
        'dependencies': {
            'downstream': ['core.module.update']
        }
    }),
    action=do_action
))

wf.insert('core.module.finishUpdate', ['analysis.reprobug'])
wf.register()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions