Skip to content

bug: upgrade mechanism uses Python file import as IPC, enabling arbitrary code execution via crafted .py files on USB #112

@RockyOmvi

Description

@RockyOmvi

Describe the bug

The upgrade mechanism communicates between versions by writing Python .py files (upgraded_from.py, upgraded_to.py) containing dict/string literals to disk, then immediately importing them. This is executed Python code by design — an attacker who can write to the app directory can inject arbitrary code that runs with the application's privileges.

The EXE_DIR is often on a USB drive (since BusKill is designed to run from a USB kill cord), making physical write access a realistic threat scenario.

Code reference

src/packages/buskill/__init__.py:782-783,832-833:

from upgraded_from import UPGRADED_FROM
...
from upgraded_to import UPGRADED_TO

src/packages/buskill/__init__.py:2198-2206:

with open( os.path.join( new_version_exe_dir, 'upgraded_from.py' ), 'w' ) as fd:
    fd.write( 'UPGRADED_FROM = ' +str(contents) )
...
with open( os.path.join( self.EXE_DIR, 'upgraded_to.py' ), 'w' ) as fd:
    fd.write( 'UPGRADED_TO = ' +str(self.UPGRADED_TO) )

Expected behavior

Use a safe serialization format like json or configparser instead of writing and importing Python source files. For example:

# Write
import json
with open(path, 'w') as f:
    json.dump({'UPGRADED_FROM': contents}, f)

# Read
with open(path) as f:
    data = json.load(f)
    UPGRADED_FROM = data['UPGRADED_FROM']

Severity

High — arbitrary code execution via crafted .py files on the USB drive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions