test_a_kconfig_sourcing_outside_the_repository_is_refused¶
Tests › tests/test_kconfig.py
What this test is for
Why it exists
M2, 1.1.0 SECURITY AUDIT — and wider than the finding as written. kconfiglib resolves `source` against `$srctree`, and NOTHING constrained it: `source "/abs/path"` parsed a file anywhere on the machine and served its symbols, prompts and help text as this repository's configuration space. Measured against kconfiglib 14.1.
Verifies REQ-DDB-PIPE-007 REQ-DDB-QUERY-006
Given
outside = tmp_path / "outside.Kconfig"outside.write_text( 'config SENTINEL_OUTSIDE\n\tbool "leaked prompt"\n\thelp\n\t SECRET-SOURCED-HELP\n', encoding="utf-8", )
3 more
repo = tmp_path / "repo"repo.mkdir()(repo / KCONFIG_NAME).write_text( f'source "{outside}"\nconfig OWN\n\tbool "own"\n', encoding="utf-8" )
When
model = load_kconfig(discover_kconfig(repo, {}), repo)served = " ".join(f"{s.name} {s.prompt} {s.help}" for s in model.symbols) + model.error
Then
- ✓ served does not contain "SECRET-SOURCED-HELP"
- ✓ served does not contain "SENTINEL_OUTSIDE"
- ✓ model.error holds
- ✓ model.symbols is false
tests/test_kconfig.py:1319 · its file's page
What it checks (4)
assert "SECRET-SOURCED-HELP" not in served, f"outside help text was served: {served}"not attributedassert "SENTINEL_OUTSIDE" not in served, f"an outside symbol was served: {served}"not attributedassert model.error, "the refusal must be recorded, not left as an empty configuration space"observesload_kconfigviamodelassert not model.symbolsobservesload_kconfigviamodel
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 (2)
| requirement | linked by | implementers exercised |
|---|---|---|
| REQ-DDB-PIPE-007 | catalog | unknown |
| REQ-DDB-QUERY-006 | catalog | unknown |
Also reaches 2 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-CONFIG-005 measured
- REQ-DDB-PIPE-014 measured