Skip to content

fix(dsh): assert the /api/* surface in the web probe + retire the single-layer auth claim - #12

Merged
github-actions[bot] merged 2 commits into
mainfrom
feat/dsh-web-fence
Oct 6, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
feat/dsh-web-fence

Conversation

@aitrawog

@aitrawog aitrawog commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The shared dshWebTokenProbe fragment (candy/plugin-dsh/webprobe.go) — used by
BOTH the dsh: web-running verb and charly dsh status — authenticated with the
launch token and then curl'd the root GET /?token=… only. dsh web
authenticates at two layers:

  1. the per-process launch token (root GET / → 303 + cookie; tokenless → 401), and
  2. the Host/Origin browser-trust fence (dsh-client-connection's
    api-request-trust) — every /api/* call passes it before authentication; a
    non-loopback / forged Host returns 403.

A GET /-only probe cannot see the fence, and the dsh-cli skill repeated the
now-known-false single-layer claim ("dsh-web-app >= 0.1.5-rc.x authenticates every
request").

This change:

  • webprobe.go — after the token exchange, make one /api/* call with the
    cookie. The exchange failure propagates (so layer 1 is still asserted exactly as
    before), and the /api/* call rejects 403 (the fence), 000 (no response)
    and 5xx. Document both layers and the --trusted-host host-side requirement —
    which this in-box probe (always dialing 127.0.0.1) cannot itself observe, stated so
    nobody reads more into a green run than it earns.
  • webprobe_test.go — lock in the propagation and the 403/000/5xx rejections.
  • charly.yml (dsh-cli skill + the candy-entity wording) — retire the false claim.

Closes #11.

Addressing the round-1 BLOCK

#1 (R4a/R10 regression). Appending the /api/* call made the fragment's exit
status the final if, silently discarding a failed token exchange: a bad/expired
token gave C=401, the if was false, and the probe exited 0 while layer 1 was
broken. The exchange now propagates via || { echo …; rm -f "$J"; exit 1; } on the
cleanup path. #2 (overclaim). if [ "$C" = "403" ] failed only on exactly 403, so
000/401/404/5xx/3xx all exited 0 while the prose claimed the API "actually
answers". The assertion is now a case rejecting 403/000/5xx, and the prose at every
site says precisely that. #3 (sweep accuracy). The false single-layer claim lived
in the dsh-cli skill, not the candy entity — the candy entity described the UI
as "token-authenticated" (accurate). Its wording is still tightened to match the
probe; the body no longer overstates which site carried the claim.

How tested

The Go unit test locks the shape (and fails without the change)

$ cd candy/plugin-dsh && GOWORK=off go test ./...
ok  	github.com/opencharly/plugin-dsh/candy/plugin-dsh	0.004s
?   	github.com/opencharly/plugin-dsh/candy/plugin-dsh/cmd/serve	[no test files]
?   	github.com/opencharly/plugin-dsh/candy/plugin-dsh/params	[no test files]

TestDshWebTokenProbeAuthenticates now requires the exchange-failure propagation and
the 403)/000)/5??) rejection arms — all absent from the pre-change fragment, so
the test is red against the old code.

The changed fragment ran LIVE against the real host web UI

The fragment IS the changed artifact. Extracted verbatim from the built function and
executed against the running dsh web on this host:

$ bash /tmp/opencode/frag.sh ; echo "exit=$?"
exit=0

The two failure modes the BLOCK named, executed live:

$ DSH_HOME=/tmp/badhome bash -c "$(cat frag.sh)"      # web-token = WRONGTOKEN
curl: (22) The requested URL returned error: 401
dsh web token exchange failed on 127.0.0.1:3080 (bad or expired launch token, or the web UI is down)
exit=1
$ DSH_HOME=/tmp/nohome bash -c "$(cat frag.sh)"       # no token file
no dsh web token at /tmp/nohome/web-token — the dsh entrypoint captures it on service start
exit=1

The auth matrix it exercises, measured separately on the same host:

GET /            Host=evil.invalid      -> 401
GET /api/models  Host=evil.invalid      -> 403
GET /api/models  Host=loopback, tokened -> 404   (past the fence; the API answers)
$ dsh web --help | grep trusted-host
  --trusted-host <authority...>  extra authority the /api browser-trust fence accepts (host or host:port; repeatable)

Structural gate

$ charly box validate
charly box validate: OK — checked 1 candy, 7 distros, 7 builders; 0 warnings, 0 errors

The compiled-in plugin

charly dsh status / the dsh: verb are compiled into charly (the pod-lifecycle
reverse channel has no out-of-process form). The in-box dispatch is unchanged by this
diff; the changed code path is the fragment string, exercised live above and locked by
the Go test. The cross-repo consumer is opencharly/pod-dsh's check-dsh-pod, which
drives the dsh: web-running verb.

Rulebook compliance

  • R0 — loaded /charly-internals:plugin, /charly-tools:dsh-cli,
    /charly-tools:dsh, /charly-internals:git-workflow before editing.
  • R1 — two anomalies: the doc-vs-reality divergence (the shipped claim is false for
    /api/*), and the exit-status regression the first version of this change introduced
    (a failed exchange swallowed by the appended if); both are recorded and fixed here.
  • R2 — the fragment, its test, and every claim site move together; nothing deferred.
  • R3 — the probe lives ONCE in webprobe.go, shared by both call sites.
  • R4 — no sleeps/retries; the probe asserts real HTTP statuses and fails loudly.
  • R4a — the code does what the prose says at every site; the --trusted-host
    host-side requirement is stated as a host requirement, not worked around.
  • R5 — the false claim is deleted from the dsh-cli skill and the candy-entity
    wording aligned, in this one change.
  • R6 — branch + PR; git status clean before each commit; no force-push.
  • R7 — the changed fragment ran live in all three cases (good token → 0; bad token
    → 1; no token → 1) and the unit test fails without it.
  • R8 — no emitted artifact changes; the plugin's Describe/schema are untouched.
  • R9 — GOWORK=off against the worktree module.
  • R10 — the plugin's own gate (go test, charly box validate) plus the live
    fragment runs; the cross-repo live bed is pod-dsh's check-dsh-pod.

Change classification

Plugin Go source + its unit test + candy/skill docs. Class gate: go test ./...,
charly box validate, and the changed fragment executed live in all three cases.

Agent: dsh-tui-install · session ses_eefd1f32fffeNl8ajvmzJ0hGLk
Assisted-by: OpenCode ollama-cloud deepseek-v4.1-flash (fully tested and validated)

…gle-layer auth claim

The shared dshWebTokenProbe fragment authenticated with the launch token and
curled the root GET /?token=… only. `dsh web` authenticates at TWO layers: the
launch token AND the Host/Origin browser-trust fence (api-request-trust), which
every /api/* call passes BEFORE authentication — a forged/non-loopback Host
returns 403 while / still loads. A GET /-only probe cannot see that fence.

- webprobe.go: after the token exchange, make one /api/* call with the cookie and
  fail on a 403, so the probe proves the app's API surface answers, not merely that
  / responds. Document both layers and the `--trusted-host` host-side requirement
  (which this in-box probe, always dialing 127.0.0.1, cannot itself observe).
- webprobe_test.go: lock in the /api/* assertion.
- candy + dsh-cli skill: retire "authenticates every request".

Closes #11

Assisted-by: OpenCode ollama-cloud deepseek-v4.1-flash (fully tested and validated)
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Review — BLOCK

Head SHA: ad056674191ca5ba44b0d4407de0ca2f4fc91340 (branch: feat/dsh-web-fence)

Change class: candy (plugin-dsh) Go source + unit test + candy/skill docs — runtime class.

Blocks

  1. R4a / R10 — candy/plugin-dsh/webprobe.go: the probe no longer fails when the layer‑1 token exchange fails (regression).
    The old fragment ended with the token-exchange curl, so the fragment's exit status was that curl's status — a bad/expired token (GET /?token=$T → 401, curl -f exits 22) failed the probe. The new fragment appends J=…; curl …; C=…; rm …; if [ "$C" = "403" ]; then …; exit 1; fi, so the fragment's exit status is now the final if (0 when C != 403), and the first curl's failure is silently discarded. A wrong/expired token therefore yields C="401" (or "404"), the if is false, and the probe exits 0 — reporting success while layer 1 is broken. This directly contradicts the body ("the probe asserts both [layers]") and the shipped comment's "curl -f … fails on any non-2xx", and it is not caught by the new test (which only checks substrings). Fix: propagate the exchange failure explicitly (e.g. curl -fsS -o /dev/null -c "$J" "…/?token=$T" || { echo "…"; rm -f "$J"; exit 1; }, or set -e), and keep the rm -f "$J" cleanup on that path. Also cover the bad-token case in the pasted live evidence / test.

  2. R1 / R4a — candy/plugin-dsh/webprobe.go: the /api/* assertion does not do what the prose claims.
    if [ "$C" = "403" ] fails only on exactly 403. 000 (no response / curl error), 401, 404, 5xx and any 3xx all exit 0. The new comment ("That second call proves the app's API surface actually answers"), the charly.yml text ("it proves the app's API surface actually answers and not merely that / responds"), and the body ("so the probe proves the app's API surface actually answers") therefore overclaim: the second call proves only that the fence did not return 403 — a broken 5xx API or an unreachable API (000) still passes. Either make the code actually assert the API answered (reject 000/5xx, or assert the expected status) or correct the prose at all three sites.

  3. A1 / R5 — body↔diff mismatch: the "candy entity" claim site is not swept.
    The body states the false single-layer claim ("dsh-web-app >= 0.1.5-rc.x authenticates every request") shipped "in webprobe.go, verb.go, control.go, the candy entity, and the dsh-cli skill", and the Summary bullet says charly.yml covers "candy + dsh-cli skill". But the only charly.yml hunk is the dsh-cli-skill list text (@@ -77,11 +77,17 @@ dsh-cli-skill:); no candy-level description:/entity hunk appears in the diff. Either the false claim survives in the candy entity (R5 hard-cutover violation) or the body overstates the sweep (A1/T3). Reconcile — paste the candy-entity text showing the claim is gone (or that it never carried it).

Verdict: BLOCK


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

…the web probe

Round-1 BLOCK findings on the plugin-dsh PR:

- #1 (R4a/R10 regression): appending the /api/* call made the fragment's exit
  status the final `if`, silently discarding a failed token exchange — a bad or
  expired token yielded C=401/404, the `if` was false, and the probe exited 0 while
  layer 1 was broken. The exchange now propagates: `curl … || { echo …; rm -f "$J";
  exit 1; }` on the cleanup path.
- #2 (R1/R4a overclaim): `if [ "$C" = "403" ]` failed only on exactly 403; 000
  (no response), 401, 404, 5xx and 3xx all exited 0, so the "proves the API
  surface actually answers" prose overclaimed. The assertion is now a `case` that
  rejects 403 (the fence), 000 (no response) and 5xx; the prose at every site says
  exactly that.
- #3 (A1/R5): the false single-layer claim lived in the dsh-cli skill, NOT the
  candy entity — the candy entity described the UI as "token-authenticated"
  (accurate). Its wording is still tightened to say the token is exchanged on /
  and an /api/* call asserted, so it matches the probe.

Verified live: a good token exits 0; a bad token exits 1 (the layer-1 guard); a
missing token file exits 1.

Assisted-by: OpenCode ollama-cloud deepseek-v4.1-flash (fully tested and validated)
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Review — PASS

Head SHA: 7416d320f0f09e7898c342534401e291ddb4681f (branch: feat/dsh-web-fence)

Security screen: PASS — no scope mismatch, no secrets/egress, no weakened guardrails, no supply-chain change; PR prose treated as data.

Checklist: All applicable rules PASS or NA. Change class: candy (plugin-dsh) Go source + unit test + candy/skill docs (runtime class). The changed fragment string is exercised live (3 cases) and locked by the unit test; the exchange failure now propagates (|| { … rm -f "$J"; exit 1; }) and the /api/* case rejects 403/000/5xx, matching the prose at every site; the candy-entity charly.yml hunk is present and the body no longer overstates which site carried the claim.

Comment disposition — Comment 6018601714 (@github-actions[bot]): stale-superseded. Its three findings were raised against head ad056674…; re-derived against the current head, all are resolved: (1) the token-exchange failure now propagates via the || { … exit 1; } arm (webprobe.go); (2) the /api/* assertion is now a case rejecting 403)/000)/5??), so the "actually answers" prose is accurate; (3) a candy-level charly.yml hunk (@@ -14,8 +14,9 @@ plugin-dsh:) is present and the body now correctly attributes the false claim to the dsh-cli skill, not the candy entity.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) October 6, 2026 14:38
@github-actions
github-actions Bot merged commit 0baf7ba into main Oct 6, 2026
1 check passed
charly-auto-merge Bot added a commit that referenced this pull request Oct 6, 2026
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.

plugin-dsh: the web probe checks only GET / — it cannot see the Host/Origin fence that 403s /api/*

1 participant