Skip to content

Detect mailcap.findmatch pickle payloads#69

Open
massy-o wants to merge 1 commit into
mmaitre314:mainfrom
massy-o:codex/detect-mailcap-findmatch
Open

Detect mailcap.findmatch pickle payloads#69
massy-o wants to merge 1 commit into
mmaitre314:mainfrom
massy-o:codex/detect-mailcap-findmatch

Conversation

@massy-o
Copy link
Copy Markdown

@massy-o massy-o commented May 14, 2026

Summary

  • classify mailcap.findmatch as a dangerous pickle global
  • add regression coverage for a pickle payload that references mailcap.findmatch

Why

mailcap.findmatch can execute a matching mailcap entry test command via os.system(). Treating it as suspicious only leaves CLI scans with zero dangerous globals and exit code 0.

Testing

  • uv run --with-editable . --with pytest --with numpy --with py7zr pytest tests/test_scanner.py::test_scan_pickle_bytes_flags_mailcap_findmatch tests/test_scanner.py::test_scan_pickle_bytes

Comment thread src/picklescan/scanner.py
"imaplib": {"IMAP4_stream"}, # IMAP4_stream executes commands via subprocess.Popen(command, shell=True)
"lib2to3.pgen2.grammar": {"Grammar.loads"},
"lib2to3.pgen2.pgen": {"ParserGenerator.make_label"},
"mailcap": {"findmatch"}, # mailcap.findmatch executes matching entry test commands via os.system()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Self-review: this promotes mailcap.findmatch from suspicious to dangerous because the callable can execute a mailcap test command via os.system() during unpickling.

Comment thread tests/test_scanner.py
)


def test_scan_pickle_bytes_flags_mailcap_findmatch():
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Self-review: the regression payload mirrors the bypass shape without executing a real shell command in the test; the scanner only needs to see the mailcap.findmatch global.

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.

1 participant