Skip to content

test(fixture): intentionally vulnerable app for advisory-scanning pipeline [DO NOT MERGE] - #23

Open
matheusht wants to merge 3 commits into
mainfrom
test/intentional-vuln-ghsa
Open

test(fixture): intentionally vulnerable app for advisory-scanning pipeline [DO NOT MERGE]#23
matheusht wants to merge 3 commits into
mainfrom
test/intentional-vuln-ghsa

Conversation

@matheusht

Copy link
Copy Markdown
Owner

⚠️ Intentionally vulnerable — do not merge to a deployed environment

Test fixture for the GitHub Advisory Database scanning pipeline. Everything
added here lives under fixtures/vulnerable-app/, is not imported by
src/redthread, and is not on any runtime path.

What this PR plants

Dependency advisories (requirements.txt, package.json) — pins chosen so
each maps to a published GHSA:

Package Pinned Advisory CVE
PyYAML 5.3.1 GHSA-8q59-q68h-6hv4 CVE-2020-14343
Jinja2 2.10 GHSA-462w-v97r-4m45 CVE-2019-10906
requests 2.19.1 GHSA-x84v-xcm2-53pg CVE-2018-18074
urllib3 1.24.1 GHSA-mh33-7rrq-662w CVE-2019-11324
Flask 0.12.2 GHSA-5wv5-4vpf-pj6m CVE-2018-1000656
Pillow 8.1.0 GHSA-8vj2-vgrf-5rv6 CVE-2021-25287
cryptography 3.3.2 GHSA-x4qr-2fvf-3mr5 CVE-2023-23931
lodash 4.17.11 GHSA-jf85-cpcp-j695 CVE-2019-10744
minimist 1.2.0 GHSA-vh95-rmgr-6w4m CVE-2020-7598
handlebars 4.0.13 GHSA-q42p-pg8m-cqh6 CVE-2019-19919
axios 0.21.0 GHSA-4w2v-q235-vp99 CVE-2020-28168

Source-level weaknesses (app.py) — SQL injection, OS command injection,
unsafe yaml.load and pickle.loads, SSTI, path traversal, SSRF,
verify=False, MD5 password hashing, hardcoded credentials, debug=True on
0.0.0.0. Each is annotated inline with the secure approach.

.github/workflows/codeql.yml — so the above actually produces
code-scanning alerts. Analysis only; it never opens PRs.

Commit layout

Split into three commits so the introducing commit for each class of finding is
individually addressable when testing advisory → commit correlation:

  • 130afd3 dependency manifests
  • 138b297 vulnerable application code
  • 0ad5900 CodeQL workflow

Existing CI

Unaffected — CI lints src/ and tests tests/, neither of which this touches.

Notes

  • Dependabot alerts fire from the dependency graph without extra config.
    Dependabot version-update PRs would need a .github/dependabot.yml;
    deliberately left out here to avoid a burst of automated PRs. Easy to add if
    you want fixing-PR signal to correlate against.
  • A follow-up "fix" PR reversing all of this gives the
    introducing-commit / fixing-commit pair.

…ersions

Intentionally vulnerable test fixture for the advisory-scanning pipeline.
Pins PyYAML 5.3.1, Jinja2 2.10, requests 2.19.1, urllib3 1.24.1,
Flask 0.12.2, Pillow 8.1.0 and cryptography 3.3.2 — each has a published
GHSA — plus lodash/minimist/axios/handlebars on the npm side.

Not installed by the project and not on any runtime path.
Plants SQL injection, OS command injection, unsafe yaml.load and pickle
deserialization, SSTI, path traversal, SSRF, disabled TLS verification,
MD5 password hashing and hardcoded credentials so code scanning has
deterministic findings to report.

Each weakness is annotated inline with the secure approach that the real
implementation would use.
Runs on push/PR to main so the vulnerable fixture produces code-scanning
alerts. Analysis only — it never opens pull requests.
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

conn = sqlite3.connect("users.db")
cur = conn.cursor()
query = f"SELECT id, email FROM users WHERE username = '{username}'" # noqa: S608
cur.execute(query)
validate ``host`` against a strict allowlist or an IP/hostname regex first.
"""
host = request.args.get("host", "127.0.0.1")
output = subprocess.check_output(f"ping -c 1 {host}", shell=True)
tags, and validate the resulting dict against a schema (pydantic) before
using any of it.
"""
return {"config": yaml.load(request.data)}
tags, and validate the resulting dict against a schema (pydantic) before
using any of it.
"""
return {"config": yaml.load(request.data)}
JSON, and if the payload must be trusted across a boundary, sign it
(HMAC-SHA256) and verify the signature before parsing.
"""
return {"session": str(pickle.loads(request.data))}
before the request goes out.
"""
url = request.args.get("url", "")
resp = requests.get(url, verify=False, timeout=10)
before the request goes out.
"""
url = request.args.get("url", "")
resp = requests.get(url, verify=False, timeout=10)
"""
url = request.args.get("url", "")
resp = requests.get(url, verify=False, timeout=10)
return {"body": resp.text[:500]}
MD5 is both broken for collision resistance and far too fast to resist
offline cracking.
"""
return hashlib.md5(password.encode()).hexdigest() # noqa: S324
# SECURE APPROACH: bind 127.0.0.1 behind a reverse proxy, debug off, and
# serve through a production WSGI server (gunicorn/uvicorn) rather than
# Werkzeug's development server.
app.run(host="0.0.0.0", port=5000, debug=True)

@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: 0ad5900a28

ℹ️ 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 on lines +35 to +36
Opening this branch as a PR should produce Dependabot alerts for the manifests
above and code-scanning alerts for `app.py`. The follow-up "fix" PR reverses

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Test dependency alerts only after merging to the default branch

Dependabot generates repository alerts from manifests on the default branch, not from manifests added only on a pull-request branch. Therefore, opening this fixture as the promised do-not-merge PR will produce the CodeQL results but not the Dependabot alerts needed for the advisory-to-commit experiment. Use a dependency-review/advisory scan that runs against the PR contents, or test the Dependabot portion in a disposable repository where the fixture can become the default branch.

Useful? React with 👍 / 👎.

Comment on lines +6 to +8
Every file here is deliberately insecure. It is not imported by `src/redthread`,
is not on any runtime path, and must never be packaged, deployed, or executed
outside a throwaway sandbox.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Exclude the vulnerable fixture from source distributions

When a source distribution is built, Hatch includes tracked repository files by default because the project only restricts the wheel target and has no sdist exclusion. As a result, release builds can contain this executable vulnerable app and its deliberately vulnerable manifests despite the stated packaging boundary. Add an explicit Hatch sdist exclusion for fixtures/vulnerable-app/.

Useful? React with 👍 / 👎.

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.

2 participants