test_no_command_valued_option_survives_a_hostile_doxyfile¶
Tests › tests/test_doxyfile_injection.py
What this test is for
Why it exists
TABLE-DRIVEN ON PURPOSE. The previous fix forced INPUT_FILTER, FILTER_PATTERNS and FILTER_SOURCE_FILES and its docstring declared the path closed. `QHG_LOCATION` then executed anyway — doxygen runs qhelpgenerator, and `HTML_EXTRA_FILES` copies a repo file into the output tree with its exec bit intact to supply the path. Verified against 1.9.8.
Verifies REQ-DDB-PIPE-014
Given
doxyfile = tmp_path / "Doxyfile"doxyfile.write_text( "PROJECT_NAME = probe\nINPUT = .\n" + "".join(f"{k} = /bin/sh\n" for k in _EXEC_VALUED) + "GENERATE_QHP = YES\nGENERATE_HTML = YES\nHTML_EXTRA_FILES = ./pwn.sh\n", encoding="utf-8", )
When
text = _build_doxyfile_content(doxyfile, None, None, False, tmp_path, "")for key in _EXEC_VALUED: values = _assignments(text, key) assert values, f"{key} is never assigned, so the repo's value stands" assert not values[-1], ( f"the LAST {key} assignment is {values[-1]!r}; doxygen takes the last one, so the " f"repo's command still runs" )for key in _UNUSED_GENERATORS: values = _assignments(text, key) assert values and values[-1].upper() == "NO", ( f"{key} ends as {values[-1:]!r}; clew reads only the sqlite3 database, so every " f"other generator is surface it does not need" )
Then
- ✓ _assignments(text, "HTML_EXTRA_FILES")[-1] equals ""
tests/test_doxyfile_injection.py:185 · its file's page
What it checks (4)
assert values, f"{key} is never assigned, so the repo's value stands"observes_assignmentsviavaluesassert not values[-1], ( f"the LAST {key} assignment is {values[-1]!r}; doxygen takes the last one, so the " f"repo's command still runs" )observes_assignmentsviavaluesassert values and values[-1].upper() == "NO", ( f"{key} ends as {values[-1:]!r}; clew reads only the sqlite3 database, so every " f"other generator is surface it does not need" )observes_assignmentsviavaluesassert _assignments(text, "HTML_EXTRA_FILES")[-1] == "", ( "HTML_EXTRA_FILES still copies a repo-chosen file into the output tree with its exec " "bit preserved, which is what supplies an attacker a runnable path" )observes_assignments
Where the product reaches it
No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.
Call flow
What it reaches
Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.
Requirements it verifies (1)
| requirement | linked by | implementers exercised |
|---|---|---|
| REQ-DDB-PIPE-014 | catalog | unknown |
Also reaches 2 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-INDEX-001 measured
- REQ-DDB-PIPE-003 measured