Skip to content

WIP: OSCMD2:Add oscmdpatches report for Command Injection analysis#280

Open
dvorak42 wants to merge 4 commits into
static-analysis-engineering:masterfrom
dvorak42:dvorak42/add_oscmdpatches
Open

WIP: OSCMD2:Add oscmdpatches report for Command Injection analysis#280
dvorak42 wants to merge 4 commits into
static-analysis-engineering:masterfrom
dvorak42:dvorak42/add_oscmdpatches

Conversation

@dvorak42

Copy link
Copy Markdown
Contributor

No description provided.

@dvorak42

Copy link
Copy Markdown
Contributor Author

@waskyo Could you do a first pass over this, before I ask @sipma to review/merge it.

@dvorak42 dvorak42 changed the title WIP: Add oscmdpatches report for Command Injection analysis WIP: OSCMD2:Add oscmdpatches report for Command Injection analysis Jun 15, 2026

@waskyo waskyo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some questions and minor comments!

Comment thread chb/cmdline/reportcmds.py
return True
return target.name in xtargets


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: one too many empty lines

Comment thread chb/cmdline/reportcmds.py
if include_target(calltgt):
if calltgt.is_so_target:
so_function = cast("SOFunction", cast("StubTarget", calltgt).stub)
for po in instr.proofobligations():

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about moving this check to an in-function util function like include_target? That way the loop is not so unwieldy.

Comment thread chb/cmdline/reportcmds.py

patch_records = []

for construction_iaddr in os_cmd_construction.keys():

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we process these in sorted order like we do in report_patch_candidates?

Comment thread chb/cmdline/reportcmds.py
pc_content["annotation"] = instr.annotation
pc_content["faddr"] = faddr
pc_content["iaddr"] = instr.iaddr
if instr.iaddr in os_cmd_delegations:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when could this check be false?

Comment thread chb/cmdline/reportcmds.py
pc_content["faddr"] = faddr
pc_content["iaddr"] = instr.iaddr
if instr.iaddr in os_cmd_delegations:
pc_content["os-iaddrs"] = os_cmd_delegations[instr.iaddr]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does the key name (os-iaddrs) translate to?

Comment thread chb/cmdline/reportcmds.py
buffersize, sizeorigin = calculate_buffer_size(stackframe, argoffset, instr)
fn_args.append({"type": "pointer", "max-length": buffersize, "size-origin": sizeorigin})
else:
fn_args.append({"type": "unknown"})

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should log a warning here? (which would normally cause the rest of the pipeline to fail)

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

Successfully merging this pull request may close these issues.

2 participants