Skip to content

Fix fail-closed handling for pickle parse errors in joblib files#356

Open
phenggeler wants to merge 1 commit into
protectai:mainfrom
phenggeler:fix/joblib-parse-error-fail-closed
Open

Fix fail-closed handling for pickle parse errors in joblib files#356
phenggeler wants to merge 1 commit into
protectai:mainfrom
phenggeler:fix/joblib-parse-error-fail-closed

Conversation

@phenggeler

Copy link
Copy Markdown

When pickletools.genops() encounters unparseable bytes mid-stream (common in joblib hybrid serialization), parsing halts without extracting remaining opcodes. Previously this was silently treated as "no issues found". Now parse failures in pickle-like files trigger a CRITICAL sentinel finding.

Changes:

  • Add _source_looks_like_pickle_stream() to detect pickle-like extensions
  • Modify _list_globals() to preserve parse context and defer error handling
  • Modify scan_pickle_bytes() to fail-closed when parse fails with no extracted globals
  • Fix aggregation bug: errors and issues were mutually exclusive due to if/elif logic
  • Add unit tests for sentinel behavior

When pickletools.genops() encounters unparseable bytes mid-stream (common in
joblib hybrid serialization), parsing halts without extracting remaining opcodes.
Previously this was silently treated as 'no issues found'. Now parse failures in
pickle-like files trigger a CRITICAL sentinel finding.

Changes:
- Add _source_looks_like_pickle_stream() to detect pickle-like extensions
- Modify _list_globals() to preserve parse context and defer error handling
- Modify scan_pickle_bytes() to fail-closed when parse fails with no extracted globals
- Fix aggregation bug: errors and issues were mutually exclusive due to if/elif logic
- Add unit tests for sentinel behavior
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