Skip to content

fix(apps): drop the app web origin label regexes, document its shared site - #37670

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/app-web-origin-follow-ups
Nov 15, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/app-web-origin-follow-ups

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: The app web origin from #36967 validates its host label without a regex, and its docs say what the origin does and does not separate.

These are the points from the maintainer review of #36967, taken after it merged:

  • The project takes no regex parsing or validation in product code. feat(apps): serve app web origins over the dashboard connection #36967 added two regexes: _LABEL_RE in apps/app_web_origin.py, used by parse_app_host, and LABEL_RE in website/src/app-sdk/webOrigin.ts, used by appWebOrigin. This was the review's one blocking point.
  • The docs call each app origin "its own site". Every app origin may be one site, apps.localhost, so SameSite cookies do not keep one app's framed page from another app's backend. An app reading "own site" would lean on SameSite and skip its own CSRF check.
  • Authorization is dropped on the origin, and appWebOrigin answers from the dashboard's host name alone. Neither is in the app docs, so an app author finds them by debugging a blank frame.

Why it matters

The regexes break a project rule that #36967 merged with. The docs are what an app author builds against, and the "own site" wording invites a CSRF hole in the backend the origin exposes.

Not a goal

  • Forwarding Authorization on the app origin. The gateway drops every credential it could be asked to trust; this PR only documents that, and says how a framed site that needs the header gets it.
  • Any change to who is served, what is audited, the credential strip list, the response hardening or the dashboard CSP.
  • Fewer granted SEL rows. The review suggested dropping the row for a served GET, HEAD or OPTIONS. AUTOSDE.yaml requires a SEL event for every permission decision, and an admission is one, so every served request keeps its row.

What changed (motivation → approach → change)

  • apps/app_web_origin.py: _LABEL_RE is replaced by _is_dns_label(label), a plain character test: 1 to 63 characters, every one in string.ascii_lowercase + string.digits + "-", not starting or ending with -. import re is gone. The check stays local rather than going through app_name_error, because the rule is the DNS label one (63 characters, no trailing -). A name that passes it but is not an installed app still gets the same 404 from the backend lookup.
  • website/src/app-sdk/webOrigin.ts: LABEL_RE is replaced by isDnsLabel(name), the same test, with LABEL_CHARS a Set of the lowercase letters, digits and -.
  • docs/app-kit/manifest-reference.md (backend.webOrigin): "own origin", not "own site". Every app origin can count as the one site apps.localhost, so check Origin or a CSRF token on every route that changes state. Authorization is dropped, so a framed site that signs in with bearer or Basic auth needs the backend to add the header itself.
  • docs/app-kit/api-reference.md (appWebOrigin): the answer reads the dashboard's host name only, so probe the origin with a no-cors fetch first and keep the loopback frame when the probe fails.
  • docs/system-specs/modules/app-kit-platform.md §18k: the heading says origin, and the audit paragraph says why every admission is recorded. There is a new "One site for every app" paragraph, the Authorization consequence, and the probe step under Discovery.
  • docs/system-specs/modules/sel.md: the row says reads are included. docs/feature-map/README.md, the module docstring, webOrigin.ts, index.ts and the vendored kirocrew-app-sdk.mjs comment: the same wording.

Backwards compatibility

Compatible: the label test accepts and refuses exactly what the regexes did (the existing cases pass unchanged), and no route, header, response or SDK answer changes.

Removes nothing: the label rule accepts and refuses the same names, and every SEL row #36967 writes is still written.

Tests

  • The existing label cases pass unchanged, and each side gains the boundaries it was missing. In test_parse_app_host, 63 characters and 0 are accepted, and x- and a_b are refused. In webOrigin.test.ts, a, 0, a-b and 63 characters are accepted, and é and a\n are refused. webOrigin.test.ts: 22 passed. eslint is clean.
  • test_each_serve_and_refusal_is_audited now also sends GET, HEAD and OPTIONS. Each is served (200, and the backend sees all three), and each leaves a granted row, along with the POST, the WebSocket open and the refusal.
  • test/test_app_web_origin.py: 72 passed. test_user_facing_doc_links.py, test_check_feature_map.py and the test_sel*.py suites: 563 passed.
  • The app web origin, security header, composition contract, SSM trust site, routes facade, manifest, doc link and feature map suites: 320 passed. The feature-map, comment-history and sync-io-in-async gates pass against main. flake8, mypy and black are clean.

Proof: not provable -- other: the label rewrite keeps the regexes' accept and refuse set, which the label tests pin; the rest is documentation

Manual verification

N/A: a validation rewrite pinned by the tests above, and documentation.

Related Issues

Refs #36965

Sibling sweep

Swept: git show 860a01b -- src website/src | grep -nE "re.compile|RegExp|= /^"
Siblings: none -- #36967 added exactly the two label regexes replaced here, and no other file in it parses with a regex

Pattern harvest

Rule candidate: semgrep
Pattern: a new re.compile(...) or regex literal in product code under src/ or website/src/, which the project does not take and no gate caught here

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 15, 2026 19:16
@bolichen97
bolichen97 requested a review from CrysisDeu November 15, 2026 19:16
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of c3df5821777c37331f0acf16d879cba2c5aab21c — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. Both validators now run plain character tests that accept the same set the regexes did, and the doc changes stop the "own site" wording from suggesting SameSite is enough without a CSRF check.

Notes

  • The old Python re.match with $ also accepted a label ending in a newline ("a\n"), and the new test refuses it. That is stricter than before, not identical. It is harmless only if the host is canonicalized before this check, so the "accepts and refuses exactly what the regexes did" line should name that one case.

[DESIGN-REVIEWED] c3df582

Description read

[DESCRIPTION-READ] b4f04fa7048878c80efc5e1d63ebcf2d46f77c8636eea385fa2a6341cb5fa7ef

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of c3df5821777c37331f0acf16d879cba2c5aab21c — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing to check. The PR changes no user-visible control. It swaps the label regexes for a character test, and edits SDK comments and developer docs. Since no dashboard UI changed, the missing blind read leaves no evidence gap.

[UX-REVIEWED] c3df582

Description read

[DESCRIPTION-READ] c8e88ee26639ae50f1dc06413d55a7decd8372bc903d6cc6eb70baf949f7b4f8

That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of c3df5821777c37331f0acf16d879cba2c5aab21c — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

This is a fix for the maintainer review of #36967: the regex goes and the docs are reworded. Nothing in it is new surface, and the one possible duplicate is a small private helper.

Notes

  • Item 1 — duplicate of src/kiro_crew/dashboard/source_providers/issue_search.py:_is_jira_cloud_host: the new _is_dns_label is a second copy of the same DNS-label test (1 sibling, found by grepping ascii_lowercase + string.digits + "-", with the same length, character-set and no-leading-or-trailing-- checks). Subtraction: keep one private label test and have the other call it, rather than shipping two that can drift apart.

What this change ships

Inventory (8 items) — 7 justified

Intent: Validate the app web origin's host label without a regex, and make the app docs accurate about what the origin does and does not separate. FIX.

  1. The gateway checks the app host label with a character test instead of a regex. Duplicate of issue_search.py:_is_jira_cloud_host's label test.
  2. appWebOrigin in the SDK checks the app name the same way, without a regex. justified
  3. "Own site" becomes "own origin" in the docs, docstring and SDK comments. justified
  4. The manifest reference says Authorization is dropped and the backend must add it itself. justified
  5. New guidance: all app origins may share one site, so check Origin or a CSRF token. justified
  6. The appWebOrigin docs say to probe the origin with a no-cors fetch and keep the loopback frame if it fails. justified
  7. The SEL spec, spec text and docstring say reads get a granted row too. justified
  8. Tests add label boundary cases and GET, HEAD and OPTIONS audit rows. justified

[FIRST-PRINCIPLES-REVIEWED] c3df582

Description read

[DESCRIPTION-READ] b467ceff2a99dea0995e60f03f53497ef29e7cfef0a9853b03dfaf8c3f1f0eae

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed c3df5821777c37331f0acf16d879cba2c5aab21c — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] c3df582

Verdict parsed from the review's SHA-scoped output markers for commit c3df5821777c37331f0acf16d879cba2c5aab21c.

False positive or not applicable? A repository writer can comment:
/ai-review override fable c3df5821777c37331f0acf16d879cba2c5aab21c false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of c3df5821777c37331f0acf16d879cba2c5aab21c and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] c3df582

False positive or not applicable? A repository writer can comment:
/ai-review override gpt c3df5821777c37331f0acf16d879cba2c5aab21c false-positive: <reason, 20 to 500 characters>

… site

The project takes no regex parsing or validation in product code, and
the app web origin added two: _LABEL_RE in apps/app_web_origin.py and
LABEL_RE in website/src/app-sdk/webOrigin.ts. Both are now a plain
character test: 1 to 63 characters, each a lowercase letter, digit or
"-", not starting or ending with "-".

The docs called each app origin "its own site". Under the Public Suffix
List's default rule every app origin may share the one site
apps.localhost, so SameSite cookies do not separate apps. The docs now
say "own origin" and tell apps to check Origin or a CSRF token on
state-changing routes. They also say that Authorization is dropped on
the origin, and that appWebOrigin reads only the dashboard's host name,
so an app probes the origin before switching its frame.

Every admission stays audited, reads included: each is a permission
decision, and AUTOSDE.yaml requires a SEL event for every one. The
audit test now pins GET, HEAD and OPTIONS rows too.

Refs #36965
@bolichen97
bolichen97 force-pushed the fix/app-web-origin-follow-ups branch from 1bf91c7 to c3df582 Compare November 15, 2026 20:23
@bolichen97 bolichen97 changed the title fix(apps): drop the app web origin label regexes, audit only its writes fix(apps): drop the app web origin label regexes, document its shared site Nov 15, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

GPT 6.1 finding on 1bf91c7a06 (F1, app_web_origin.py:599: a served GET, HEAD or OPTIONS skipped _record_grant) is fixed in c3df582177 by taking that change out.

The audit reduction came from an optional suggestion on #36967. It conflicts with AUTOSDE.yaml's blocking rule that every permission decision emits a SEL event, and an admission is one. So every served request keeps its granted row, as on main. test_each_serve_and_refusal_is_audited now pins a row for GET, HEAD and OPTIONS too. The PR is down to the regex removal and the docs. The title, body and commit message say so, and spec §18k and sel.md say that reads are recorded.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 15, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates a 5% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

The new character-test label checks in Python and TypeScript accept and refuse the same names as the regexes they replace. On the Python side the label is cut from a host that has already been canonicalized and ends in .apps.localhost, so the old $ newline quirk can't arise. No other code used the removed regexes. The doc changes ("own origin", the shared apps.localhost site and CSRF advice, Authorization being dropped, the probe advice) match the code. The tests now cover the label boundary cases and confirm that reads leave granted audit rows. CI is green.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit c3df582177 · 114 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I reviewed head c3df582. The new character-based DNS label checks in the gateway and the SDK replace the two regexes. A brute-force comparison found that they accept and refuse the same names as before, except a label with a trailing newline, which the old Python pattern let through and the new check refuses. The app web origin test suite passes on this head. The extended audit test checks that GET, HEAD and OPTIONS are each relayed and each leave a granted audit row. The rest of the change is documentation, and it matches what the code does, so nothing blocks.

@KiroCrewCaptain
KiroCrewCaptain merged commit a2414a5 into main Nov 15, 2026
99 of 104 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/app-web-origin-follow-ups branch November 15, 2026 21:49
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 15, 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.

2 participants