Public: anyone can read this; the crew can change it.
A note from the app's own origin is filed as a visitor's unless it carries the forge panel's one-use proof #5377
A note or note list from the app's own origin now counts as a person's only if it carries the panel's one-use proof. Without a valid proof it is a visitor's, and admin is false. The tests I ran pass (apps-feedback, the toolbar and pill suites) and tsc is clean.
stopped parked by the crew deploy d784d74
A note or note list from the app's own origin now counts as a person's only if it carries the panel's one-use proof. Without a valid proof it is a visitor's, and admin is false. The tests I ran pass (apps-feedback, the toolbar and pill suites) and tsc is clean. I did not run the whole suite or bun scripts/design-lint.ts (nothing in src/web/ changed), and I did not exercise a real page load, because that needs a running app.
What changed
- Proof module:
src/apps/proof.tsissues and spends tokens. A token is bound to the grant cookie value and the host, is spent whether or not it matches, and is kept in memory as a hash with a one-hour life and a cap of 10,000. - Page load: in
src/apps/proxy.ts, a signed-in person's page load gets the token in the panel's script tag asdata-proof, and the page answerscache-control: private, no-store. This applies whenSec-Fetch-Destisdocument, absent, or a cross-siteiframe. A same-origin fetch of the page gets no token, and the token never goes in a URL. - Note endpoints:
POST /__forge/noteandGET /__forge/notesspend the proof from thex-forge-proofheader. Insrc/apps/feedback.ts, with a valid proof the sender is@name, the list is theirs andadminis computed. Without one, or with a reused, foreign-grant or foreign-host token, the sender isvisitor-…. A private or sealed app still opens its door to the grant holder but files an unproven note as a visitor. - Next token: every answer to a request with a valid proof carries the next token in
x-forge-proof. - Panel script:
src/apps/toolbar.tsstripsdata-prooffrom its tag on load. It sends notes and list requests one at a time through a smallapihelper, so the poll and a send cannot spend the same token, and it keeps each answer's next token. - Tests:
test/apps-feedback.test.tscovers an unproven POST as a visitor, a proven one as@alice, and reused, foreign-grant, foreign-host and made-up tokens as visitors. The page-load rule (isPageLoad) and thedata-prooftag are covered by unit tests rather than a real request, so the same-origin-fetch-gets-no-token case is not tested end to end. I also rewrote the private-app test to use a proof. - Existing tests edited:
test/apps-crew-pill.test.tsandtest/toolbar-actions.test.tscountedfetch(calls and the literalfetch("/__forge/note". Those two were wrong about the code's shape, since the notes now go through theapihelper, so I updated them.
Left out
- Tokens live in memory, so a forge restart means the open panel files as a visitor until the page is reloaded. Persisting them would be a table for little gain.
- An app's own script could read
data-prooffrom the tag before the panel strips it. The panel script isdeferred, so this is a narrowing of the exposure, not a seal.
Try it by signing in, opening an app page and sending a note from the panel, which should come through as @you. Then run fetch('/__forge/note', …) from the page's console, which should come through as visitor-….
Parked by the crew: the check failed ("RepoSource: one repository, two places to read it from > a mirror reports its stages in order and ends holding the repo") and the decider saw no point in another try
A note or note list from the app's own origin now counts as a person's only if it carries the panel's one-use proof. Without a valid proof it is a visitor's, and
adminis false. The tests I ran pass (apps-feedback, the toolbar and pill suites) andtscis clean. I did not run the whole suite orbun scripts/design-lint.ts(nothing insrc/web/changed), and I did not exercise a real page load, because that needs a running app.What changed
src/apps/proof.tsissues and spends tokens. A token is bound to the grant cookie value and the host, is spent whether or not it matches, and is kept in memory as a hash with a one-hour life and a cap of 10,000.src/apps/proxy.ts, a signed-in person's page load gets the token in the panel's script tag asdata-proof, and the page answerscache-control: private, no-store. This applies whenSec-Fetch-Destisdocument, absent, or a cross-siteiframe. A same-origin fetch of the page gets no token, and the token never goes in a URL.POST /__forge/noteandGET /__forge/notesspend the proof from thex-forge-proofheader. Insrc/apps/feedback.ts, with a valid proof the sender is@name, the list is theirs andadminis computed. Without one, or with a reused, foreign-grant or foreign-host token, the sender isvisitor-…. A private or sealed app still opens its door to the grant holder but files an unproven note as a visitor.x-forge-proof.src/apps/toolbar.tsstripsdata-prooffrom its tag on load. It sends notes and list requests one at a time through a smallapihelper, so the poll and a send cannot spend the same token, and it keeps each answer's next token.test/apps-feedback.test.tscovers an unproven POST as a visitor, a proven one as@alice, and reused, foreign-grant, foreign-host and made-up tokens as visitors. The page-load rule (isPageLoad) and thedata-prooftag are covered by unit tests rather than a real request, so the same-origin-fetch-gets-no-token case is not tested end to end. I also rewrote the private-app test to use a proof.test/apps-crew-pill.test.tsandtest/toolbar-actions.test.tscountedfetch(calls and the literalfetch("/__forge/note". Those two were wrong about the code's shape, since the notes now go through theapihelper, so I updated them.Left out
data-prooffrom the tag before the panel strips it. The panel script isdeferred, so this is a narrowing of the exposure, not a seal.Try it by signing in, opening an app page and sending a note from the panel, which should come through as
@you. Then runfetch('/__forge/note', …)from the page's console, which should come through asvisitor-….Closes #5354