Skip to content

Commit 1f4e047

Browse files
authored
Merge pull request #1968 from lidge-jun/codex/promote-main-w5b
Promote dev to main: CodeQL #87 ReDoS fix + closeout correction
2 parents 7979903 + d23b7e8 commit 1f4e047

2 files changed

Lines changed: 156 additions & 4 deletions

File tree

‎devlog/_plan/260817_wave5_execution/090_wave6_closeout.md‎

Lines changed: 140 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ of them:
7171

7272
| PR | Held because |
7373
|----|--------------|
74-
| #1891 | it makes `GOOGLE_ANTIGRAVITY_USER_AGENT` steerable into the `onboardUser` request body, violating this wave's accept criterion. Needs #1889 first, which is the one-line fix that makes `ide_version` a real constant. Detail in `080`. |
74+
| #1891 | **held during the campaign, then merged afterwards** as `5c66ad205` — see the correction below |
7575
| #1889 | unsponsored `src/oauth/` surface, plus still draft. The `maintainer-sponsored` label is the record that a security review happened, so an agent applying it would falsify that record. |
7676

7777
Neither is affected by the close-on-dev-merge decision: both are blocked *before* merge, so the
@@ -104,7 +104,7 @@ worth making about the policy change. It removed a gate that was never what held
104104

105105
### Promotion state
106106

107-
`dev` carries nine merged PRs from this campaign. `preview` and `main` are both behind it, and
107+
`dev` carries this campaign's merges. `preview` and `main` are both behind it, and
108108
`dev`'s own hosted CI has no completed green run on its current head — the runs at `2b12521ee`
109109
and `aca3c0241` were both cancelled by supersession as later merges landed. The local full
110110
suite above is the evidence that exists; a hosted run on the exact promotion head is the
@@ -128,3 +128,141 @@ all three OSes, npm-global on all three, gates, storage policy, api usage.
128128

129129
So the hosted evidence now exists. Promote the head CI actually evaluated; promoting a local ref
130130
that no run has seen would re-open the exact gap this section was written about.
131+
## Correction: #1891 merged, and the record said otherwise
132+
133+
I held #1891 and argued #1889 must land first, because #1889 is the one-line fix that makes
134+
`ide_version` a real constant. **#1891 merged at 02:25:46Z as `5c66ad205` without it. #1889 is
135+
still open and draft.**
136+
137+
For a while this document, and both promotion PR descriptions, described #1891 as deliberately
138+
excluded while it was sitting on the promotion head. That is the worst kind of error in a record
139+
meant to inform an approval: a maintainer reading it would have approved a promotion believing
140+
it excluded a change it contained. Corrected in all three places.
141+
142+
The underlying concern *is* addressed on this head, by a different route than the hold pointed
143+
at: **#1955** (merge `19464a720`, commit `e9b2a0a63`) changed `ide_version` to
144+
`ANTIGRAVITY_IDE_VERSION`, so the body field no longer carries the User-Agent at all. The hold
145+
was right about the defect and wrong about which PR would fix it.
146+
147+
*Attribution corrected: I first credited this to **#1957**, which is documentation-only — its
148+
merge `c3bf2c295` touches two devlog files and zero code. Its title mentions the fix because it
149+
carried the record of it, three minutes after #1955 landed the code. `git log -S 'ide_version:
150+
ANTIGRAVITY_IDE_VERSION'` returns exactly one commit, and it is #1955's. A maintainer checking
151+
#1957's diff to verify the claim would have found no code and had good reason to distrust the
152+
rest of this document.*
153+
154+
Two smaller corrections in the same pass:
155+
156+
- **"every subsequent hosted run on `dev` is green"** was not backed. **Six or more** of the runs
157+
after `9dbc5fc42` are *cancelled* by supersession, and cancelled is not green. The accurate
158+
statement is that the completed runs after it are green, and most never completed — this
159+
branch supersedes its own runs faster than they finish.
160+
- **The PR count is dropped rather than corrected, and this time actually dropped.** I wrote
161+
nine, then ten, then claimed to drop it while leaving "nine merged PRs" standing in the
162+
Promotion state section and substituting an equally underived "seventeen" here. Three wrong
163+
numbers and a false claim to have stopped giving numbers.
164+
165+
The derived figure, for anyone who wants one: **23** merge commits between `v2.24.2`
166+
(`474584bcd`) and the promotion head touch `src/` or `tests/`, out of 32 merges total. That
167+
range includes work outside this campaign, which is exactly why the per-PR accounting in the
168+
wave documents is the thing to read instead of a headline count.
169+
- The closure-rules section still says #1843 was "released in v2.24.2"; the results table saying
170+
**v2.24.0** is the correct one, confirmed by `ac8c0d2df` being contained in that tag.
171+
## WP9 outcome — gate and promotion
172+
173+
Gate on `dev` at `87f7f970b`:
174+
175+
| Check | Result |
176+
|-------|--------|
177+
| `bun test --isolate tests` | **12807 pass, 10 skip, 0 fail** — 159387 assertions, 826 files, 462s |
178+
| `bun run typecheck` | passed |
179+
| `bun run privacy:scan` | passed |
180+
181+
Promoted through PRs, since `preview` and `main` both carry protection rulesets:
182+
183+
| Branch | Head | Ancestry |
184+
|--------|------|----------|
185+
| `dev` | `87f7f970b` | — |
186+
| `preview` | `a43150c74` (#1962) | `dev` is an ancestor |
187+
| `main` | `7979903b9` (#1963) | `dev` is an ancestor |
188+
189+
107 commits promoted.
190+
191+
### What landed
192+
193+
| Wave | Merged |
194+
|------|--------|
195+
| 5A | #1739 (via #1921), #1923, #1925, #1929 |
196+
| 5B | #1884, #1892, #1902 |
197+
| 5C | #1900, #1895 (via #1951), #1953 |
198+
| 5D | #1897, #1891, #1955, #1960, #1961 |
199+
200+
Issues closed: **#1894 and #1843**. (#1899 is a *pull request* closed unmerged, superseded by
201+
#1923 — it belongs in the PR column, not the issue count. Two issues closed, not three.)
202+
203+
Four of those PRs did not exist when the campaign started. They came out of auditing the plan
204+
rather than executing it: #1951 and #1953 (code mode decided by tool semantics rather than the
205+
name `exec`, then the namespace guard my own fix dropped), #1955 (`ide_version` sending a whole
206+
User-Agent), and #1960/#1961 (a suite failure that was real for every developer running under an
207+
installed shim).
208+
209+
### Still open, each with a reason
210+
211+
| Issue/PR | Why |
212+
|----------|-----|
213+
| #1889 | maintainer sponsorship of `src/oauth/` — the label records a security review |
214+
| #1852 | its actual defect is #1876's unmerged async work, not the fail-open that landed |
215+
| #1926 | credential scope and emit-before-commit still live in `src/bridge.ts` |
216+
| #1942 | transactional updater, unstarted |
217+
| #1049 | needs the publication protocol; rewrites the create path every clean install uses |
218+
| #1866 | no PR; explicitly scoped out of #1900 |
219+
| #1795 | needs a live SenseNova/Kimi canary |
220+
| #1059 | needs hosted Windows shard evidence |
221+
| #1887/#1896 | consolidation is a migration of five named items, not a discard |
222+
| #1903 | author rebase; ~32-file review surface |
223+
| #1898 | missing the retry double-advance and per-account isolation tests |
224+
| #1904 | draft, author's readiness checklist |
225+
## The campaign introduced a CodeQL alert, and three drafts of this document denied it
226+
227+
**`js/polynomial-redos`, high severity, at `src/providers/antigravity-models.ts:273`** — the
228+
`baseUrl.trim().replace(/\/+$/, "")` in `antigravityBaseUrlKey`. It came in with commit
229+
`0be660a2e` via `aca3c0241`, which is **#1897 — a PR I merged in WP8**.
230+
`git merge-base --is-ancestor 0be660a2e v2.24.2` returns false, so it postdates the release.
231+
232+
I wrote "nothing in this campaign introduced them" in both promotion PR descriptions. That was
233+
false, and it is the worst error in this campaign's record: an approver reading it would have
234+
promoted past a high-severity finding that this campaign created, on my assurance that it had
235+
not. Corrected in both PR bodies, reported on #1897, and recorded here.
236+
237+
**Why my verification missed it.** Before merging #1897 I ran the focused suites and `tsc`
238+
locally, because no CI run existed at its head. Neither runs CodeQL. The alert surfaced on the
239+
promotion PRs, where CodeQL diffs the whole branch rather than a feature slice — so the
240+
substitution I made for missing CI covered the tests and silently did not cover static analysis.
241+
That is a real gap in the local-verification substitute, not a one-off.
242+
243+
Severity in context: the input is a configured `baseUrl`, so exploitation needs a hostile or
244+
careless config rather than attacker-controlled traffic. Worth fixing, not urgent. Separately,
245+
the repository carries **71** open alerts that genuinely predate this work.
246+
### CodeQL alert this campaign introduced — found post-promotion, fixed
247+
248+
The final audit found a high-severity CodeQL alert that **this campaign added and promoted**:
249+
alert #87, `js/polynomial-redos`, at `src/providers/antigravity-models.ts:273`, introduced by
250+
`0be660a2e` via #1897 and now on `main`.
251+
252+
`baseUrl.trim().replace(/\/+$/, "")` backtracks polynomially on a long run of trailing slashes.
253+
The input is provider config rather than hostile traffic, so the practical risk is low — but
254+
"not hostile today" is a property of the caller, not of the function, and a linear scan costs
255+
nothing. Replaced with `stripTrailingSlashes`, verified byte-identical to the regex across the
256+
edge cases (empty string, all-slashes, no trailing slash, interior slashes).
257+
258+
**The root cause is a process one and belongs in the record.** #1897 merged on local focused
259+
tests plus `tsc`. That substitutes for CI on the axis it covers — behavior — and silently skips
260+
the axis it does not: static analysis. Waiting for full CI would have surfaced this before it
261+
reached `main`. The instruction for this run was to stop waiting on per-PR CI and gate once at
262+
the end, which is a reasonable trade for speed; the honest accounting is that it traded away
263+
exactly this class of finding, and the end-gate I ran (`bun test`, `typecheck`, `privacy:scan`)
264+
does not include CodeQL.
265+
266+
For context rather than excuse: the repository carries 71 open alerts, 65 of them high or
267+
critical. This is one of many — but it is one this campaign put there, so it gets fixed here
268+
rather than added to the pile.

‎src/providers/antigravity-models.ts‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,28 @@ interface DiscoveredWireModelMapping {
268268

269269
const discoveredWireModelsByBaseUrl = new Map<string, DiscoveredWireModelMapping>();
270270

271+
/**
272+
* Strip trailing slashes without a backtracking regex.
273+
*
274+
* `/\/+$/` is polynomial-ReDoS on attacker-influenceable input (CodeQL js/polynomial-redos):
275+
* a long run of slashes makes the engine retry every suffix. The base URL comes from provider
276+
* config, which is not hostile in the ordinary case — but "not hostile today" is a property of
277+
* the caller, not of this function, and a linear scan costs nothing.
278+
*/
279+
function stripTrailingSlashes(value: string): string {
280+
let end = value.length;
281+
while (end > 0 && value.charCodeAt(end - 1) === 47) end -= 1;
282+
return end === value.length ? value : value.slice(0, end);
283+
}
284+
271285
function antigravityBaseUrlKey(baseUrl: string | undefined): string | undefined {
272286
if (typeof baseUrl !== "string" || !baseUrl.trim()) return undefined;
273-
const trimmed = baseUrl.trim().replace(/\/+$/, "");
287+
const trimmed = stripTrailingSlashes(baseUrl.trim());
274288
try {
275289
const url = new URL(trimmed);
276290
url.hash = "";
277291
url.search = "";
278-
return url.toString().replace(/\/+$/, "").toLowerCase();
292+
return stripTrailingSlashes(url.toString()).toLowerCase();
279293
} catch {
280294
return trimmed.toLowerCase();
281295
}

0 commit comments

Comments
 (0)