Skip to content

Show how hidden complexity becomes real-world bugs: security pitfalls, vulnerability data and charts - #3

Merged
EMRahman merged 4 commits into
mainfrom
analysis/dependency-risk
Oct 30, 2026
Merged

EMRahman merged 4 commits into
mainfrom
analysis/dependency-risk

Conversation

@EMRahman

@EMRahman EMRahman commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

Connects the repo's thesis (readable Python hides behavior you can't predict from the interface) to real-world evidence. It adds seven security pitfalls, a data analysis of every Python vulnerability in OSV joined with the dependency graphs of the top 1,000 PyPI packages, and a landing-page table that maps each kind of hidden complexity to its pitfalls, advisory counts and real CVEs.

README: "How the complexity shows up in production"

A new table near the top. Each row is a mechanism, with the pitfalls that demonstrate it, PyPI advisories since 2023 and real cases. Examples: path joins → 507 path-traversal advisories → tarfile CVE-2007-4559; parsing cost → 549 denial-of-service advisories → urllib3/idna ReDoS CVEs.

New: Security pitfalls (53–59)

# Pitfall Runnable example
53 os.path.join(base, "/etc/hosts") discards base ✅
54 tarfile extraction before 3.14 (CVE-2007-4559); shows 3.13 vs 3.14 behavior and filter="data" ✅
55 urllib.request forwards Authorization/Cookie to another host on redirect (verified on 3.13 and 3.14) ✅ (two servers on localhost)
56 Regex backtracking (ReDoS) ✅
57 Decompression bombs ✅
58 Loading data runs code (pickle, torch.load) Documentation only
59 Signing-key confusion (PyJWT) Documentation only

58 and 59 have no examples, because demonstrating them means writing a working payload or forging a token.

New: Complexity in the wild and analysis/

  • 7,032 unique OSV advisories (PYSEC/GHSA duplicates merged), deps.dev dependency graphs for the top 1,000 packages, PyPI yanked releases, OpenSSF Scorecard and malicious-package records.
  • Organized by mechanism: code you never chose, parsers on untrusted input, conveniences hiding protocol decisions, one parameter with two meanings, and the layer below Python. Measurement caveats are in appendices.
  • Headline findings:
    • urllib3 and cryptography are the highest-exposure dependencies (weighted by reach, 70–95% indirect).
    • Resource exhaustion is 34% of dependency advisories vs 13% across PyPI.
    • 2026 has more than 3× any previous year's advisories.
    • A third of top packages have yanked a release.
  • Three charts (advisories per year, reach vs advisories, weakness mix) as light and dark SVGs via <picture>, using a palette validated for color-vision deficiency. Markdown tables carry the same data.
  • analysis/ has every script plus a CSV snapshot; analysis/README.md reproduces every number and chart.

Other

  • #43 gains its real-world case: CVE-2012-1150, the reason hash() is randomized.
  • CONTRIBUTING asks for an "In the wild" paragraph when a pitfall has a documented real-world case.

Test plan

  • All 57 examples pass on CPython 3.13.7 and 3.14.7, both normally and under -X dev
  • Every internal link, heading anchor and chart path resolves; new external URLs return 200
  • analysis/report.py reproduces every figure in the docs; charts inspected in both themes
  • Real-world claims checked against advisory text or primary sources (PEP 706, PyTorch announcement, and behavior run locally)
  • CI passes on 3.10 to 3.14

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T16:25:47.748624Z 2d66084 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0bd36137a6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread analysis/fetch_deps.py Resolved
Comment thread analysis/fetch_yanked.py Resolved
Comment thread analysis/analyze.py Resolved
Ehsan Rahman and others added 2 commits October 30, 2026 16:09
Join 7,032 unique OSV advisories with deps.dev dependency graphs for
the top 1,000 PyPI packages, PyPI yanked releases, OpenSSF Scorecard
and OSV malicious-package records.

- docs/dependency-risk.md: findings, tables, recommendations, method
  and limitations.
- analysis/: scripts that regenerate every number, plus a CSV snapshot
  (30 October 2026).
- README: Part III link.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- docs/security.md (53-59): path joins with absolute paths, tarfile
  extraction (CVE-2007-4559), credentials forwarded on redirect by
  urllib.request, regex backtracking, decompression bombs, unsafe
  deserialization, signing-key confusion. Each lists the CVEs it
  produced; 58 and 59 are documented without attack code.
- examples/53-57: runnable, self-checking demonstrations of the
  harmless-to-demonstrate cases, verified on 3.13 and 3.14.
- README: "How the complexity shows up in production" table mapping
  each mechanism to its pitfalls, PyPI advisory counts and real cases.
  #43 gains CVE-2012-1150 as its real-world case.
- docs/dependency-risk.md: restructured by mechanism (code you never
  chose, parsers on untrusted input, conveniences hiding protocol
  decisions, ambiguous parameters, the layer below Python), with
  measurement caveats moved to appendices.
- analysis/charts.py and docs/img: three charts in light and dark SVG,
  using a palette validated for color-vision deficiency.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@EMRahman
EMRahman force-pushed the analysis/dependency-risk branch from 0bd3613 to f1fba0f Compare October 30, 2026 16:10
- fetch_deps/fetch_yanked/fetch_scorecard: only reuse cache entries
  that hold data. Failed fetches were cached as {"error": ...} and
  skipped forever, contradicting the documented rerun-after-failure.
- fetch_yanked: treat any non-false `yanked` value, including an empty
  string, as yanked. Refetching all 1,000 indexes gives the same 331
  packages and 940 yanked releases.
- analyze.py: only count graphs for the current top 1,000, so a
  refreshed ranking in an old data directory can't inflate reach.
  report.py: same filter for yank totals and Scorecard lookups.

All published numbers reproduce unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@EMRahman

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 369e9bf630

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread analysis/fetch_scorecard.py Resolved
fetch_scorecard read ["version"] from the dependency cache whenever the
file existed. After a failed graph fetch that file holds only an error,
so every run raised KeyError before any request and could never
recover. Fall back to the package's default version when the cache has
no usable version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@EMRahman

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 2d66084505

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@EMRahman
EMRahman merged commit 7078615 into main Oct 30, 2026
5 checks passed
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