bug: RBAC adapter makes distinct one-time public JWTs share an environment-key fingerprint
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 55/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- typescript
- Bereich
- authentication
Rechercherichtung
Start by reading internal-packages/rbac/src/bearerCredentials.ts where the public JWT result and oneTimeUse are produced, then apps/webapp/app/services/routeBuilders/apiBuilder.server.ts where authentication.apiKey is populated, and apps/webapp/app/services/apiAuth.server.ts where getOneTimeUseToken hashes it. Follow the trigger route apps/webapp/app/routes/api.v1.tasks.$taskId.trigger.ts to see how the token reaches the run service. A fix is done when distinct public JWTs produce distinct one-time-use identifiers while private-key and non-one-time paths stay unchanged, backed by regression tests.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
At current main commit ba9448974f4b026efa62f2cb447c076d9a25b04f, authenticateRequestForApiBuilder() sets authentication.apiKey to result.environment.apiKey, including for an authenticated public JWT. The task trigger route then calls getOneTimeUseToken(authentication), which hashes authentication.apiKey.
Consequently, distinct one-time JWTs for the same environment produce the same one-time-use identifier: the environment key is hashed instead of the presented JWT. Once that identifier is present on a run, a fresh JWT can be rejected as already used.
Source path
- Bearer resolver returns the authenticated environment plus
oneTimeUsefor a public JWT. - apiBuilder adapter places the environment key in
authentication.apiKey. - One-time-use helper hashes that field.
- Trigger route passes the resulting value to the run service. The engine converts a
oneTimeUseTokenuniqueness conflict to the already-used-token error.
Minimal illustration
This dependency-free example illustrates the collision; the source-extracted regression harness described below additionally executes the real functions.
const assert = require('node:assert/strict');
const { createHash } = require('node:crypto');
const environment = { apiKey: 'NONSECRET_OFFLINE_ENVIRONMENT_KEY' };
// Models the adapter after successful authentication of each distinct JWT.
function bridge(presentedJwt) {
return { type: 'PUBLIC_JWT', oneTimeUse: true, apiKey: environment.apiKey };
}
function oneUseId(auth) {
return createHash('sha256').update(auth.apiKey).digest('hex');
}
const jwtA = 'synthetic-distinct-jwt-a';
const jwtB = 'synthetic-distinct-jwt-b';
assert.notEqual(jwtA, jwtB);
// Fails: these must be distinct, but both hash the environment key.
assert.notEqual(oneUseId(bridge(jwtA)), oneUseId(bridge(jwtB)));
Source-extracted verification
Using Node 22.22.3 and TypeScript 5.9.3, an offline harness extracts the actual authenticateRequestForApiBuilder, getOneTimeUseToken and presentedBearerToken functions from that pinned commit and strips their types. Successful RBAC authentication is the fixture; the adapter and hashing functions are real upstream code. Two differently signed synthetic JWTs for one synthetic environment collide with the pristine adapter. No provider requests or real credentials are involved.
A proposed adapter correction passes eight checks: the baseline collision; distinct fresh-token fingerprints; identical-token replay identity; a minimal uniqueness model; non-one-time behavior; unchanged private-key behavior; forwarded RBAC denial; and fail-closed handling of an absent bearer token. The uniqueness model uses a Set, not the full run-engine database; full upstream integration testing remains necessary.
Suggested correction
Preserve the presented bearer JWT in authentication.apiKey for a successfully authenticated publicJWT subject, while leaving other subject types unchanged. The existing presentedBearerToken(request) helper can supply it after RBAC succeeds. Fail closed if that value is absent. Do not remove one-time protection or widen scopes.
const publicJwt = result.subject.type === "publicJWT"
? presentedBearerToken(request)
: undefined;
if (result.subject.type === "publicJWT" && !publicJwt) {
return { ok: false, status: 401, error: "Invalid or missing public JWT" };
}
// In the existing authentication object:
apiKey: publicJwt ?? result.environment.apiKey,
Alternatively, carry the presented-token identity in a dedicated field and hash that explicitly. The candidate has not been deployed, and all authentication paths need maintainer review before accepting it.
Hosted symptom and limits
A separate isolated Development check using SDK/CLI 4.8.1 and a verified V2 worker returned HTTP 422 with the one-time-token-used error on a fresh one-use token's only recorded caller submission. No new run appeared in the subsequent task/time-filtered read. Connection validation used a different read-only token. The caller stopped and did not retry.
This is consistent with the source defect, but we cannot attest which backend build processed that hosted request or its database state. We are not treating the local test as proof of a deployed fix. Related symptom report: #3780; a shared cause is not assumed.
Could you confirm whether the cloud task-trigger route uses this adapter and review the token identity passed to getOneTimeUseToken? The reproduction, regression tests and proposed patch are ready to share. No credentials, customer data, project IDs or run IDs are included here.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 16.5k
- Forks
- 1.5k
- Ø Merge
- 1 T. 15 Std.
- Gemergte PRs (30 T.)
- 17
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus triggerdotdev/trigger.dev
-
bug: retry.fetch ignores the caller's abort signal and retries aborted requestsEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
triggerdotdev/trigger.dev#5116 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug: Chat transport crashes on Safari < 17.4: AbortSignal.any is not a functionEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
triggerdotdev/trigger.dev#5098 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug: Side menu items lose their active state on detail pagesEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
triggerdotdev/trigger.dev#5088 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug: RBAC loader logs "plugin found but failed to load" when @triggerdotdev/plugins is simply not installedEvtl. wieder frei @itsfaryal hat das vor 17 Tagen übernommen, und es ist kein Pull Request offen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
triggerdotdev/trigger.dev#5083 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
triggerdotdev/trigger.dev#5072 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in triggerdotdev/trigger.dev
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug platform-android
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Termix-SSH/Mobile#146 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
devswha/herdr-web-ui#3875 ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
-
area: runtime chore cli consistency dependencies developer-experience difficulty: easy discovery documentation enhancement good first issue help wanted hygiene json-output packaging priority: P3 tests version
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag