Skip to content

Fix command injection via bclass field in binary loading (CVE) ##security#25714

Open
trufae wants to merge 1 commit intomasterfrom
claude/fix-binary-loading-safety-mWZUR
Open

Fix command injection via bclass field in binary loading (CVE) ##security#25714
trufae wants to merge 1 commit intomasterfrom
claude/fix-binary-loading-safety-mWZUR

Conversation

@trufae
Copy link
Copy Markdown
Collaborator

@trufae trufae commented Apr 3, 2026

The bclass field from binary metadata (smd, pebble, io plugins) was passed
unsanitized to r_core_cmdf() in cfile.c, allowing arbitrary command execution
via crafted binaries containing newlines and shell metacharacters in the
bclass field.

Multi-layered fix:

  • Replace r_core_cmdf("o %s") with direct r_core_file_open() API call in
    cfile.c to eliminate the command injection vector entirely
  • Sanitize bclass at the source in bin_smd, bin_io, bin_pebble plugins
  • Harden r_str_sanitize() to also strip newlines, backslashes, quotes,
    and the r2 shell escape character (!)
  • Sanitize file paths in cmd_debug.inc.c get_bin_info() before passing
    to r_core_cmdf on macOS
  • Replace r_core_cmdf("e anal.cc=...") with direct r_config_set() API
    call in cbin.c to avoid command parsing of binary metadata

Fixes #25708

https://claude.ai/code/session_01XrfBCsbvdH1yZToZLeLQh3

The bclass field containing "://" triggered an IO plugin redirection
in cfile.c that passed unsanitized binary metadata to r_core_cmdf(),
enabling arbitrary command execution via crafted smd/pebble/io binaries.

- Rewrite the bclass redirection in cfile.c to validate the URI scheme
  against registered IO plugins and use direct API calls (r_core_file_open
  + r_core_bin_load) instead of r_core_cmdf. Add a recursion guard to
  prevent infinite redirection loops.
- Use r_core_cmd_callf instead of r_core_cmdf in cmd_debug.inc.c
  get_bin_info() to avoid r2 command parser interpreting metacharacters
  in debug map filenames.
- Sanitize dbglink from ELF .gnu_debuglink sections in cmd_info.inc.c
  before use in command output strings.
- Harden r_str_sanitize() to also cover newlines, backslash, quotes
  and the r2 shell escape character (!).

Fixes #25708

https://claude.ai/code/session_01XrfBCsbvdH1yZToZLeLQh3
@trufae trufae force-pushed the claude/fix-binary-loading-safety-mWZUR branch from 5d0882e to bdc12bf Compare April 3, 2026 17:46
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.

command injection via bclass (affects smd,pebble,io plugin)

2 participants