Skip to content

Detect mailcap.findmatch pickle payloads#346

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

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

Conversation

@massy-o
Copy link
Copy Markdown

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

Summary

  • add mailcap.findmatch to the unsafe pickle globals list
  • cover the detection with a focused regression test that scans a pickle payload through ModelScan

Why

mailcap.findmatch can execute a matching mailcap entry test command via os.system(). Without this entry, a pickle payload using that callable can scan cleanly even though unpickling can execute shell behavior.

Testing

  • uv run --with-editable . --with pytest pytest tests/test_pickle_unsafe_globals.py

return mailcap.findmatch, (caps, "text/plain")


def test_scan_flags_mailcap_findmatch(tmp_path) -> None:
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 uses the public ModelScan().scan() path instead of importing the pickle scanner directly, so the regression follows the same path users hit from the CLI/API.

Comment thread modelscan/settings.py
"pdb": "*",
"shutil": "*",
"asyncio": "*",
"mailcap": [
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 keeps the fix scoped to the specific stdlib gadget observed in the PoC. mailcap.findmatch can execute a mailcap test command through os.system(), so it belongs with the CRITICAL pickle globals.

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