Skip to content

fix(server): read a percent-encoded path id as the route does in the demo brand guard - #1963

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/demo-brand-encoded-path
Nov 2, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/demo-brand-encoded-path

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

The demo brand guard now reads a percent-encoded path id the way the route does. The guard read the raw param, while Express hands the route the decoded one. For example, PATCH /api/content/%34a0…/status reaches the route as 4a0…, but the guard's guidOf('%34a…') found no id, so brandsNamedBy checked no brand. A normal session could get past the demo brand's read-only guard this way, for example to start AI cost on the demo brand with POST /content/%xx…/brief. Each route's own access check still stopped any write to another workspace; only the demo guard was skipped. Found in the pre-push security review of #1949.

What changes

No migration, no web change.

Related issue

None. Follow-up from the security review of #1949.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. As a signed-in member, call a guarded write on the demo brand's row with one character of the id percent-encoded, e.g. PATCH /api/content/%34a…/status. It is now refused like the plain id (402 for the demo brand).
  2. Send a badly encoded id such as %E0%A4%A: 400 "Invalid path".
  3. Unit tests:
    • demo-brand.test.js: an encoded demo brand or row is refused, and a real brand passes.
    • acting-user.test.js: an encoded row id is read as the route reads it (another workspace's brand is refused), and a bad encoding is a 400.

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • npm run lint passes
  • npm run format:check passes
  • Changes are focused — one concern per PR
  • Help article updated under help/ (or no user-visible change)

CI passed on this branch (1d6be35), run on the fork (https://github.com/cihan-gyk/ansvisor/actions/runs/41349154341): schema is up to date; web format:check, lint, typecheck, all tests and yarn build pass; server lint, format:check and all tests pass.

🤖 Generated with Claude Code

cihan-gyk and others added 2 commits November 1, 2026 23:49
…demo brand guard

Express hands a route its params decoded, while the demo brand guard read
them raw: /content/%34a0…/brief named no id the guard knew, so a session
could start a write on the demo brand. The guard now decodes path params
the same way, and answers 400 to one that isn't valid percent-encoding, as
Express does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… too

The acting-member check (ansvisor#1949) reads the brand through the demo brand
guard's `brandsNamedBy`, which now throws BadPathParam for a path param that
isn't valid percent-encoding. Answer 400 "Invalid path" there as well,
instead of a 500. Test: an encoded row id is read as the route reads it
(another workspace's brand is refused), and a bad one is a 400.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gkhngyk
gkhngyk merged commit 2b24098 into ansvisor:main Nov 2, 2026
6 checks passed
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.

2 participants