Skip to content

fix(web,update): PathEscape ollama model names; respect NXD_NO_BROWSER#68

Merged
tzone85 merged 1 commit into
mainfrom
fix/ollama-url-pathescape-openbrowser-skip
Jun 11, 2026
Merged

fix(web,update): PathEscape ollama model names; respect NXD_NO_BROWSER#68
tzone85 merged 1 commit into
mainfrom
fix/ollama-url-pathescape-openbrowser-skip

Conversation

@tzone85

@tzone85 tzone85 commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Summary

Two low-severity hardening fixes from the 2026-06-11 security audit, bundled because they touch two tiny files.

  • Ollama URL traversal (SEC-L1). ollamaRemoteDigest interpolated the model name and tag directly into /v2/library/<name>/manifests/<tag>. An operator-supplied model name with a / (accidental library/gemma4) would traverse into a different API subtree; a tag with spaces produced a malformed URL and a confusing 400. Wrap both with url.PathEscape.
  • openBrowser leaks token via ps (SEC-L2). openBrowser passed the full token-bearing URL as a process argument to open / xdg-open. ps is world-readable on most multi-tenant systems. Add NXD_NO_BROWSER=1 opt-out for headless / CI / SSH environments. The URL is still printed via log.Printf for discovery.

Test plan

  • TestOllamaRemoteDigest_PathEscapesModelName captures r.URL.EscapedPath() and asserts a slashed model name comes through as %2F instead of segment-splitting.
  • TestOpenBrowser_RespectsNxdNoBrowser sets the env var and runs the function (no panic, no leaked process).
  • go build ./..., go vet ./..., go test ./... -count=1 -timeout 240s all green locally.

Audit traceability

Security findings SEC-L1, SEC-L2 (2026-06-11 sweep).

Two low-severity hardening fixes from the 2026-06-11 security audit,
bundled because they live across two tiny files.

- ollamaRemoteDigest interpolated the model name and tag directly into
  the /v2/library/<name>/manifests/<tag> URL. An operator-supplied
  model name with a slash (e.g. accidental "library/gemma4") would
  traverse into a different registry API subtree; a tag with spaces
  produced a malformed URL and a confusing 400. Wrap both segments
  with url.PathEscape so the URL structure is invariant under any
  config value.
- openBrowser fired `open` / `xdg-open` with the full token-bearing
  URL as a process argument. On most systems `ps` is world-readable
  by every local user — multi-tenant CI runners and shared dev hosts
  could leak the auth token to other users on the machine. Add
  NXD_NO_BROWSER=1 opt-out so operators in headless / SSH / CI
  environments can suppress the launch. The URL is still printed via
  log.Printf for operator discovery.

Surfaced by the 2026-06-11 security audit (SEC-L1, SEC-L2).

New tests:
- TestOllamaRemoteDigest_PathEscapesModelName captures
  r.URL.EscapedPath() and asserts a slashed model name comes through
  as %2F instead of segment-splitting.
- TestOpenBrowser_RespectsNxdNoBrowser sets NXD_NO_BROWSER and runs
  the function (no panic, no leaked process).
@tzone85 tzone85 merged commit 650c247 into main Jun 11, 2026
9 of 10 checks passed
@tzone85 tzone85 deleted the fix/ollama-url-pathescape-openbrowser-skip branch June 11, 2026 11:15
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.

1 participant