Skip to content

fix: block legacy httplib pickle aliases#703

Merged
mldangelo merged 1 commit intomainfrom
feat/pickle-httplib-alias-coverage
Mar 13, 2026
Merged

fix: block legacy httplib pickle aliases#703
mldangelo merged 1 commit intomainfrom
feat/pickle-httplib-alias-coverage

Conversation

@mldangelo
Copy link
Member

@mldangelo mldangelo commented Mar 13, 2026

Summary

  • treat Python 2 httplib pickle globals the same way as existing http and http.client network-danger module coverage
  • add runtime-only regressions for import-only, REDUCE, second-stream, zip-entry, parity with http.client, and a safe stdlib negative
  • add an Unreleased changelog entry for the alias hardening

Validation

  • uv run pytest tests/scanners/test_pickle_scanner.py -q -k "httplib or http_client_coverage_unchanged or safe_stdlib_import_remains_non_failing"
  • uv run ruff format modelaudit/ tests/
  • uv run ruff check --fix modelaudit/ tests/
  • uv run ruff check modelaudit/ tests/
  • uv run ruff format --check modelaudit/ tests/
  • uv run mypy modelaudit/
  • uv run pytest -n auto -m "not slow and not integration" --maxfail=1

Summary by CodeRabbit

  • Bug Fixes
    • Expanded pickle security scanning to treat legacy httplib module the same as http.client, detecting threats in import-only and REDUCE payloads across all formats.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: c31042ee-7c55-4b49-b791-90e3bddffedd

📥 Commits

Reviewing files that changed from the base of the PR and between 698859d and 864a168.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • modelaudit/scanners/pickle_scanner.py
  • tests/scanners/test_pickle_scanner.py

Walkthrough

The pickle scanner's security blocklist is expanded to treat legacy httplib module references as dangerous, equivalent to http.client. A single module addition to the dangerous modules list is accompanied by comprehensive test coverage validating httplib detection across various pickle payload scenarios including import-only globals, REDUCE operations, and multi-stream contexts.

Changes

Cohort / File(s) Summary
Security Configuration
CHANGELOG.md, modelaudit/scanners/pickle_scanner.py
Added "httplib" to the ALWAYS_DANGEROUS_MODULES list to treat legacy httplib pickle globals as security threats, with corresponding changelog entry documenting the fix.
Test Coverage
tests/scanners/test_pickle_scanner.py
Added 88 lines of new test cases covering httplib detection scenarios: import-only globals, REDUCE operations, multi-stream payloads, ZIP-embedded entries, and benign stdlib imports to validate cross-stream contamination resilience and edge-case handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰✨ A pickle's old friend, httplib by name,
Now flagged as dangerous in security's game!
The scanner now catches both new and the old,
With tests multiplied, our defenses grow bold!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: block legacy httplib pickle aliases' clearly and specifically describes the main change: adding httplib to the dangerous modules blocklist to treat legacy Python 2 pickle globals consistently with modern http.client.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/pickle-httplib-alias-coverage
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@mldangelo mldangelo merged commit 24b789a into main Mar 13, 2026
28 checks passed
@mldangelo mldangelo deleted the feat/pickle-httplib-alias-coverage branch March 13, 2026 23:39
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