Issue #2242: no raw sink refuses data from outside the program today (ADR-raw-sinks-1 D3,…

Open and answer this issue on GitHub.

blocked, safety · opened 2026-11-19 · updated 2026-11-20 · 7 comments

Filed by the driver from the Found: of the run of issue-2217 (#2217) (owner, 2026-11-06).

Found

no raw sink refuses data from outside the program today (ADR-raw-sinks-1 D3, Part III 13.3 say NK1308): use std::io\nuse std::fs\nfn main() throws {\n let name = io::read_line() ?? ""\n let t = fs::read_to_string(name, fs::Root::Anywhere)\n println(t)\n} gives Checked exit 0, and html::Raw(name) and process::run(name, []) give the same; NK1308 is emitted nowhere in crates/ (traced: grep finds it only in a comment in project_settings.nika); this is the part of #1253 still to build after raw sinks steps 1-3

Needs

#1253 #2216

To build

Done when

The probe or check gives the expected output the first item names from its ADR or Part I-III section, and a tests/compiler/tests/ test (or the named check) that failed on the unfixed tree is green; or the probe already passes on develop and a test pins it, naming the commit that fixed it; or the issue is closed as by design, naming the function or ADR.


Generated by Claude Code

Comments

keywan-ghadami, 2026-11-19

Supervisor (2026-11-19): not a decision. ADR-raw-sinks-1 D3 and Part III 13.3 already specify NK1308 for data from outside at a raw sink, so this is kind 3, a defect: the build of the rest of “Raw sinks” (#1253). Labels set to ready, safety; queued in the safety lane before “Run by path and working directory” (#2217), which waits for it.


Generated by Claude Code

keywan-ghadami, 2026-11-19

Brief queued: issue-2242


agent: builder model: opus max_turns: 200 budget_usd: 30 effort: medium —

Issue #2242

Your work order is issue #2242, inlined below with its comments. There is no brief written around it: plan your own steps from its To build list, build them in order, commit after each finished step, and end when its Done when holds (or at the limits of builder.md, reporting what is left). The facts in your prompt are Core of docs/builder-facts.md; more on a topic: nikaia run scripts/syntax.nika -- KEYWORD, a probe: nikaia run scripts/probe.nika -- SNIPPET.

Measure the issue against docs/issues.md while you work: what it lacked, what was wrong in it. That answer goes into the report’s Issue: field. A finding, a changed plan or a finished item also goes into the issue as a comment (gh api repos/Nikaia-Foundation/Nikaia/issues/2242/comments -F body=@file, ending with the Claude Code footer), rule I13.

Rules (CLAUDE.md; shared checkout)

Report (at most 15 lines, to exactly /home/user/Nikaia/docs/briefs/safety/issue-2242.md.report.md)

Fields: Result, Files, Commit, Body (optional), Fixes, Pushed, Tests, Gate, Deviation, Found, Needs, Changelog, Issue, Owner (a question for the owner), Comment (#N <text>, what to say on another issue; the driver posts it, one line each), Friction, Disk freed, and last Attribution: with your commit trailer lines below it.


Generated by Claude Code

keywan-ghadami, 2026-11-19

Run: issue-2242, Result: partial

Tokens: input 206, cache read 7470589, cache write 196334, output 56990 Cost: 4.40 USD, time 29 min 10 s, turns 103

Report

Result: partial Files: crates/nikaia-std/std.contracts tests/compiler/tests/a_line_read_from_standard_input_is_data_from_outside.nika tests/compiler/tests/a_line_read_from_standard_input_is_data_from_outside.stderr crates/nikaia-std/src/compiler/prove_terms.nika crates/nikaia-std/src/compiler/prover_walk.nika crates/nikaia-std/src/compiler/lowered/prove_terms.rs crates/nikaia-std/src/compiler/lowered/prover_walk.rs crates/nikaia-std/src/compiler/lowered.rs tests/compiler/tests/a_guard_on_a_std_predicate_proves_it_after.nika tests/compiler/tests/a_guard_on_a_std_predicate_proves_it_after.stdout Commit: 9887487c io::read_line and io::read_exact are untrusted sources (ADR-365); a13303eb a guard on a std predicate such as html::is_plain(name) makes it a fact after the guard (ADR-381 D5) Body: Cause traced. io::read_line was marked provenance = "trusted" in std.contracts, and no sink check existed anywhere. 9887487c makes read_line and read_exact untrusted, with a trusted: option. a13303eb lets a pure bool free function of std (html::is_plain) be a named property, so the precondition of html::Raw can be proved (prove_terms property_name, prover_walk prover_std_properties, prover_a_property_callee). The NK1308 check itself (prover_walk prover_raw_sink, project_check_let_raw_sinks_through with [allow], NAME:key into NK1309 and raw-sinks=warn, project.rs plumbing, 9 lines of Rust) is built and refuses the probe. It is not merged: it is commit 0254f60c3 on the local ref wip/issue-2242, without its lowered files (run lower-std after applying). Pushed: local a13303ebd55c53e9a5f644f8dbd49d2983a9039c Tests: both new tests fail on the unfixed binary $S/old/nikaia (NK1109 plus 2x NK1300; NK1300) and pass with –both-settings, together with io_lines_are_text, io_read_exact, io_standard_input_arrives_in_pieces, a_file_or_stdin_read_is_untrusted_unless_marked and the 11 named-property tests (17 ok). lower-std fixpoint clean; pre-push green. The wip check gives NK1308 on the probe; counted with it: 41 sites in the compiler, 52 in scripts/, 14 in examples/packages, 1268 in 261 tests/compiler programs. Gate: green Deviation: To build item 3 (NK1308) is built but not committed: ADR-raw-sinks-1 D8 and ADR-396 D4 (“Until those are done, the refusal is not merged”) hold the refusal until about 1375 sites in our own code build under it; most are a path from fs::read_dir or a read file, a mktemp dir or a toolchain path from process::run, under fs::Root::Anywhere. Found: none Needs: the sites of our own code moved, so the NK1308 check on wip/issue-2242 can merge (ADR-raw-sinks-1 D8): in tests/compiler, let tmp = process::run("mktemp", ["-d"]).stdout.trim().clone() followed by fs::write(f"{tmp}/p.nika", fs::Root::Anywhere, source) draws NK1308 for tmp (261 programs); the compiler reads fs::read_to_string(dir.join(name).join("Cargo.toml"), fs::Root::Anywhere) with name from fs::read_dir (project_drive.nika:611, 41 sites); scripts/drive.nika has 20 sites, scripts/agent.nika 11; each wants trusted: true at its source or a Root::Dir, issues to file per area Changelog: io::read_line and io::read_exact are untrusted sources, as io::read_to_string is (ADR-365); after a guard return if !html::is_plain(name), html::is_plain(name) is proved, as a program’s own named property is (ADR-381 D5). Issue: broke I9: the To build list has one item for the whole NK1308 refusal and leaves out the site migration that ADR-raw-sinks-1 D8 requires before merge (about 1375 sites), so Done when cannot hold in one run; broke I7: the cause is not marked, and the trace showed two (read_line trusted in std.contracts, and no sink check at all) Owner: none Comment: #1253 The NK1308 check (fs paths under Root::Anywhere or Dir(“/”), html::Raw parts with an html::is_plain guard, the process::run program; [allow], NAME:key into NK1309, raw-sinks=warn) is commit 0254f60c3 on wip/issue-2242. Still open: D6 (a pub parameter at a sink), D7 (the run-time check under warn), db::raw and http::File, a root held in a variable, a number part by its type (only a whole number the walk follows passes today), and the D10 match-of-literals arms (from_outside taints a match by its scrutinee). The sites of D8 come first. Friction: none Disk freed: none; target/nikaia-project-tests 349M, / 14G free of 252G, no new cache entry over 100 MB Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01UVxJDvbkNUUMs8HdjJ8ixV

Debrief

  1. Most cost: investigating before the first edit. I read the prover’s call path, the property machinery and the ADR’s D2/D3/D8 across a whole context, then rebuilt that knowledge after compaction. The D8 blocker showed only after I had built the NK1308 check and counted 1,375 sites (compiler 41, scripts 52, examples/packages 14, tests 1,268). Counting first would have changed the plan before any code was written.
  2. Looked up: where taint comes from (from_outside and untrusted in prover_calls.nika; provenance in std.contracts) and where a check should go (prover_calls_in). Also: the NK1302 Finding model, how named properties work (ADR-381, property_name), the warn filter in project_check.nika, the one Rust call site in project.rs, and ADR-396 D4 (“not merged until our code builds”).
  3. Checks: probes on the HEAD binary, which were useful. I also ran the lower-std/build/fixpoint cycle twice, and the first (with the sink check) was spent only to find the D8 count. Then the site count over scripts, examples and tests (~4 minutes, decisive), the 17 touched tests, pre-push, and commit dry-runs. The wasted part was building and wiring the full sink check before measuring the sites.
  4. Change that would save the most: builder.md should say: “a new refusal: before building it, run a cheap count of the sites it would hit in our own code (grep the sink, then a quick check of those files); above a few dozen, ADR-396 D4 / D8 means stage it, not merge it.”
  5. What the issue lacked:
    • broke I9: one To build item for the whole NK1308 refusal, with no item or follow-up issue for the D8 site migration, so Done when cannot hold in one run.
    • broke I7: the cause is unmarked, and there are really two: io::read_line is provenance = "trusted", and no sink check existed at all.
    • knowledge: Core | a std free predicate (html::is_plain) was no prover fact after a guard; only methods were std properties (fixed in a13303eb).
  6. Facts for the next builder:
    • Fact: Core A new refusal on outside data is merged only after every site in the compiler, scripts/, examples/, packages/ and tests/compiler builds under it (ADR-396 D4, ADR-raw-sinks-1 D8); count the sites with the prototype check before building the rest.
    • Fact: Self-hosting lower-std turns the prover’s findings straight into errors and skips project_check’s severity filters, so a warn setting there does not let the compiler’s own build through.
    • Fact: Core The tests/compiler programs taint tmp (from mktemp via process::run) and the toolchain path, so any path or program sink check hits about 260 of them.

Generated by Claude Code

keywan-ghadami, 2026-11-19

The report of the run of issue-2242 (#2242) judged this issue against docs/issues.md; the author fixes the issue by the rule it names (How a run judges its issue):


Generated by Claude Code

keywan-ghadami, 2026-11-19

The owner decided on 2026-11-19 to prove path sinks safe instead of adding trusted: at each one (“Weg 2”). This is recorded as ADR-raw-sinks-1 D11-D16 (57379dba7). The build is split into four issues, in order:

  1. A path from outside can be proved safe: Root::join, Root::path, path::is_component and is_below; trusted: comes off read_line (#2300)
  2. The tests write under fs::scratch() instead of mktemp and Root::Anywhere (#2301), needs #2300
  3. The compiler, scripts and packages pass the raw path sink check by proof, not trusted: (#2302), needs #2300
  4. A path from outside reaching a file operation is refused unless proved or allowed in the manifest, NK1308 to deny (#2303), needs all three

The check so far (0254f60c3, local ref wip/issue-2242) is also saved on the branch ccr-1df86473-m6u8d2. #2303 brings it onto develop.


Generated by Claude Code

keywan-ghadami, 2026-11-19

From the report of the run of issue-2302 (#2302):

#2302 (paths by proof in the compiler, scripts and packages) waits for the D15 keys (untrusted-paths-read/-write/-remove with source lists, manifest.nika allow_keys) and the NK1308 check on develop; neither is built, so #2302 is blocked on them


Generated by Claude Code

keywan-ghadami, 2026-11-20

Supervisor: this issue is the umbrella of the split build (#2300, #2301, #2302, #2303) and is not built as one run (its last run broke I9). Status blocked until those four are closed; it is closed then, naming them. The Found probe now gives warning[NK1308] at raw-sinks = "warn".


Generated by Claude Code

Back to Open Issues