Repository navigation
feat(secret-paths): derive and serve the request paths to mask per destination - #5595
shekhar-rudder wants to merge 5 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #5595 +/- ##
===========================================
- Coverage 93.01% 93.00% -0.01%
===========================================
Files 729 731 +2
Lines 39440 39484 +44
Branches 9257 9210 -47
===========================================
+ Hits 36687 36724 +37
- Misses 2530 2561 +31
+ Partials 223 199 -24 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
15650c8 to
57617a2
Compare
…stination Destination live events show the outbound request verbatim, including the credentials the transformer put in it. This is the transformer half of a fix: work out where each destination's declared credentials land in the request it builds, and publish that on GET /features so the data plane can mask those fields before the payload is shown. Nothing here is hand-authored per destination. A byte in the request is secret-derived iff changing a declared secret input changes it, so for every component-test fixture the generator runs the real transform twice (to find non-deterministic fields), then once per declared `secretKey` with a format-preserving decoy substituted, and records which output leaves moved. The only input is `secretKeys` from the destination definition, which is the source of truth for what counts as a credential. Two checks keep plausible-looking noise out. Each key is substituted with two different decoys, so a field that merely broke as a side effect - a lookup whose mocked response stopped matching - collapses to the same value both times and is rejected. And if substituting a decoy changes the number of requests or fields, the transform took a different branch, positions no longer line up, and the destination is marked unresolved rather than guessed at. A credential the destination fetches rather than reads from config is covered by perturbing the mocked auth response instead. Anything the derivation cannot place gets `null` - mask everything - with the reason recorded for counting. `null` rather than a sentinel path like `["*"]` because the fail-closed case is the absence of an answer, not a path: a path-shaped spelling invites being passed to sjson.Set, where `*` is a gjson wildcard that replaces the first top-level key and returns no error, masking nothing while destroying the body, on exactly the destinations we are least confident about. The endpoint is excluded from masking by decision. A URL is already visible to proxies, to TLS SNI and in the provider's own access logs, so masking it protects little while removing the most useful field for diagnosing a delivery failure - and most endpoints that look secret-carrying only do so because `secretKeys` declares an identifier sitting in the host or path. The generator classifies rather than silently drops the ones that do carry a credential: `url` where the URL is itself the shared secret, and `query` where a parameter that belongs in `params` was concatenated into the endpoint string instead and is fixable at the source. Two things make this hold over time rather than rotting: - `--check` derives the manifest and fails unless the committed file is byte-for-byte what the run would write. It catches a new destination with no entry, a transform change that moves a credential, and an upstream `secretKeys` change with masking consequences. A byte comparison is honest only because the artifact holds nothing that varies by environment - no build stamp, no content hash - so the same code and the same `secretKeys` produce the same bytes on a laptop and on a runner. Keys are sorted on emit, since directory enumeration order is not guaranteed to agree between machines, and the file is in .prettierignore so lint cannot reformat what the generator just wrote. Runs per PR via a new workflow. - `--validate` replays the corpus against the committed paths and reports any declared secret that survives masking, plus how many fixture cases back each entry. It reports rather than gates today: a few fixture secrets are short enough to collide with ordinary data. Current state: 199 destinations - 99 with derived paths, 97 with nothing to mask, 3 fail-closed. The consumer contract is stated once, in swagger/components/schemas/features.yaml.
57617a2 to
e7f93e2
Compare
… source `secretKeys` describes destination configuration, and an OAuth destination's bearer token is never configuration: the control plane mints it per account and rudder-server forwards it as an opaque blob in `metadata.secret`. Following the registry alone therefore published `[]` - the positive claim that there is nothing to mask - for all 24 OAuth destinations in the catalogue, while GOOGLE_ADWORDS_ENHANCED_CONVERSIONS sends the token in `headers.Authorization` and again in `params.accessToken`. So the derivation now has two secret sources. `secretKeys` is perturbed by name, wherever that key appears in a config. The bag is perturbed by position: every value under a `secret` object is treated as a credential, because nothing declares which of its keys are. That deliberately over-masks - the bag also carries values that are not credentials, TIKTOK_AUDIENCE's `advertiser_ids` among them - and the alternative is guessing at credential-looking key names, which fails in the direction that publishes a token. Location-scoped rather than name-scoped on purpose: feeding the bag's key names into the existing name-based walker would also rewrite same-named config fields, which is a different perturbation than the one being measured. One exception to the diff rule comes with it. A leaf that differs between two identical real runs is excluded from attribution, rightly, or a nonce would be blamed on whichever input was perturbed - but exclusion is not the same as carrying no credential. TWITTER_ADS and X_AUDIENCE sign with OAuth1, so `headers.Authorization` holds a fresh `oauth_nonce` on every run as well as `oauth_token="<the bag's access token>"`, and the whole header read as nothing to mask. A non-deterministic leaf is now also checked for containment of a runtime-bag value. That is sound only there and stays scoped to it: the bag is the one source whose plaintext the generator is holding, where `includes` is direct evidence rather than the guess it would be against a config secret that may have been hashed, signed or base64'd on the way in. Two bugs surfaced by running the derivation over destinations that used to short-circuit at `no-declared-secrets`: - GOOGLE_ADWORDS_OFFLINE_CONVERSIONS produced no request in any fixture. `run.js` never loaded `test/setup.ts`, which is how the component suite gets GOOGLE_ADS_DEVELOPER_TOKEN, so every case 400'd in `getDeveloperToken` and the destination read as "builds no request" - the same silent failure mode as the missing sandbox bundle the runner already guards against. - A bag reachable only from `dataDelivery` fixtures gated a derivation that had no case to run. SALESFORCE_OAUTH ships a networkHandler and no transform, so it failed closed as `harness-error`, a defect reported about a destination that simply has nothing to derive from. The corpus scan now counts a bag only in a case `routeFor` accepts, the same definition the derivation iterates by. The validator collects bag values too, so it cannot report a clean bill of health about a value it never looked for, and `carriesSecret` moves to the harness so both halves agree on what "this value appears here" means - `oauth-1.0a` percent-encodes its parameter values, and the generator's bare `includes` would have missed exactly what the validator then reports as a survivor. Discovery is corpus-based rather than registry-based, deliberately. `auth.type === 'OAuth'` reads like the authoritative answer, but FACEBOOK_OFFLINE_CONVERSIONS, SALESFORCE, WOOTRIC and YAHOO_DSP all read `metadata.secret` without declaring it, so gating on the registry would drop the source for destinations that use it. The corpus errs the other way - `generateMetadata` attaches a `secret` object to every case it builds - which costs a derivation that finds nothing rather than a published token. 199 destinations: 117 with derived paths, 82 with nothing to mask, 0 fail-closed. 17 destinations moved, every one gaining a credential that was previously published as nothing to mask; no destination's list shrank. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…asured Merging develop showed two things the branch could not see from its own base. EVERFLOW landed on develop after the branch was cut, so CI derived 200 destinations against a manifest holding 199. It derives `params.verification_token` from its declared `secretKeys` - the configured source, unrelated to this change. SALESFORCE derived `null` rather than `["headers.Authorization"]`, which the branch's own base could not reproduce because develop carries two Salesforce transform fixes (#5603, #5604) that change how it responds to a decoy. With the bag measured first, SALESFORCE turns out to destabilise under it: the bag moves `endpoint` and `headers.Authorization` on the cases that hold, and a later case collapses the transform entirely, which discarded every measured location and masked the destination wholesale. So the rescue is now skipped only when the bag destabilised *and* was never compared cleanly in any case. That is the case the guard was added for - a rescue result says nothing about where the bag's token went, so publishing it would be a positive claim built on unrelated evidence. When the bag was compared cleanly somewhere, its locations came from the same corroborated diff every other path comes from, and discarding them to punish an unrelated case trades a measured answer for a blunter one. 200 destinations: 118 with derived paths, 82 with nothing to mask, 0 fail-closed. Fixture-quality gaps that bound this - dual-use credential values, paths resting on a single case, a declared credential no fixture populates - are tracked separately in INT-7221, which is fixture-only. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Five of the six are fixture-quality problems, tracked in INT-7221: a credential value too short to be distinctive, identical to ordinary data in the same fixture, or spelled differently between cases. KLAVIYO is not one of them. It routes `privateApiKey` through `maskedSecrets.ts` like the rest of the corpus and its value is distinctive, so nothing about its fixtures explains the survivor - it is a candidate real finding and has to be triaged here before `--validate` can be made to gate. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|



What
Destination live events show the outbound request verbatim, including the credentials the
transformer put in it. This is the transformer half of a fix: work out where each
destination's declared credentials land in the request it builds, and publish that on
GET /featuresassecretPaths, so the data plane can mask those fields before the payload isshown.
Nothing is hand-authored per destination. There are two secret sources, and between them they
cover the two ways a destination is handed a credential:
secretKeysfrom the destination definition, the source of truth for whichconfig fields are credentials. Perturbed by name, wherever that key appears in a config.
metadata.secretbag the control plane mints per OAuth account andrudder-server forwards verbatim as an opaque blob. Nothing declares its keys, so every value
under it is treated as a credential and perturbed by position.
The second source exists because
secretKeyscannot describe it. An OAuth destination's bearertoken is never a config field —
GOOGLE_ADWORDS_ENHANCED_CONVERSIONSdeclaressecretKeys: []and still sends
Authorization: Bearer <token>, plus the same token again inparams.accessToken— so following the registry alone published "nothing to mask" for all 24OAuth destinations in the catalogue. Treating the whole bag as secret deliberately over-masks;
see Known gaps.
How the paths are derived
A byte in the request is secret-derived iff changing a secret input changes it. For every
component-test fixture the generator runs the real transform twice (to find non-deterministic
fields such as nonces and timestamps), then once per secret source with a format-preserving
decoy substituted — same length, same character class per position — so the decoy run takes the
same branches. Fields that moved are secret-derived.
Two checks keep plausible-looking noise out:
broke as a side effect collapses to the same value both times and is rejected.
different branch and the destination is marked unresolved rather than guessed at.
A credential the destination fetches rather than reads from config is covered by perturbing the
mocked auth response instead.
One thing the diff rule cannot see, and the single exception to it. A field that differs between
two identical real runs is excluded from attribution — rightly, or a nonce would be blamed on
whichever input was perturbed — but exclusion is not the same as carrying no credential.
TWITTER_ADSandX_AUDIENCEsign with OAuth1, soheaders.Authorizationholds a freshoauth_nonceon every run as well asoauth_token="<the bag's access token>"; excluded from thediff, the whole header read as nothing to mask. So a non-deterministic leaf is also checked for
containment of a runtime-bag value. That is sound only there, and stays scoped to it: the bag
is the one source whose plaintext the generator is holding, where
includesis direct evidencerather than the guess it would be against a config secret that may have been hashed, signed or
base64'd on the way in.
The contract
destType -> string[] | null, with exactly three cases: a list of paths,[]for nothing tomask, and
nullfor mask-everything. A destType absent from the map is the same case asnull.nullrather than a sentinel path like["*"]on purpose: the fail-closed case is the absenceof an answer, not a path, and a path-shaped spelling invites being passed to
sjson.Set, where*is a gjson wildcard that replaces the first top-level key and returns no error — maskingnothing while destroying the body, on exactly the destinations we are least confident about.
The full consumer contract is stated once, in
swagger/components/schemas/features.yaml.The endpoint is deliberately never masked
A URL is already visible to proxies, to TLS SNI and in the provider's own access logs, so masking
it protects little while removing the most useful field for diagnosing a delivery failure. Most
endpoints that look secret-carrying only do so because
secretKeysdeclares an identifiersitting in the host or path. The generator classifies rather than silently drops the ones that
do carry a credential, recording them in
endpointExposures:urlwhere the URL is the sharedsecret, and
querywhere a parameter that belongs inparamswas concatenated into the endpointstring instead. See Known gaps.
Staying in sync
npm run secret-paths:checkderives the manifest and fails unless the committed file isbyte-for-byte what the run would write. It catches a new destination with no entry, a transform
change that moves a credential, and an upstream
secretKeyschange with masking consequences.A byte comparison is honest only because the artifact holds nothing that varies by environment
— no build stamp, no content hash — so the same code plus the same
secretKeysproduce thesame bytes everywhere. Keys are sorted on emit, and the file is in
.prettierignoreso lintcannot reformat what the generator just wrote. Runs per PR via
.github/workflows/secret-paths.yml.npm run secret-paths:validatereplays the corpus against the committed paths and reports anydeclared secret that survives masking, plus how many fixture cases back each entry.
The loader refuses a manifest it cannot vouch for — wrong version, or
destinationsnot a map ofstring-lists — and serves
{}, which by the contract means every destination masks everything.Current state
200 destinations: 118 with derived paths, 82 with nothing to mask, 0 fail-closed.
(200 rather than 199 because develop added EVERFLOW after this branch was cut; it derives
params.verification_token, which is the configured source and nothing to do with this change.)Adding the runtime source moved 17 destinations, every one of them gaining a credential that
was previously published as nothing to mask:
GOOGLE_ADWORDS_ENHANCED_CONVERSIONS[]headers.Authorization,params.accessTokenGOOGLE_ADWORDS_OFFLINE_CONVERSIONS[]headers.AuthorizationGOOGLE_ADWORDS_REMARKETING_LISTS[]headers.AuthorizationAMAZON_AUDIENCE[]headers.Amazon-Advertising-API-ClientId,headers.AuthorizationCAMPAIGN_MANAGER,CRITEO_AUDIENCE,INTERCOM_V2,LINKEDIN_ADS,LINKEDIN_AUDIENCE,REDDIT,REDDIT_AUDIENCE,TWITTER_ADS,X_AUDIENCE,ZOHO[]headers.AuthorizationTIKTOK_AUDIENCE[]body.JSON.advertiser_ids.#,headers.Access-TokenPARDOTheaders.Pardot-Business-Unit-Idheaders.AuthorizationSNAPCHAT_CUSTOM_AUDIENCEbody.JSON.users.#.idheaders.AuthorizationNo destination's list shrank, and none became fail-closed.
SALESFORCEadditionally picks up anendpointExposures: "url"entry: its bag carriesinstanceUrl, which lands in the endpoint, andthe endpoint is excluded from masking by decision.
Two bugs surfaced by running the derivation over destinations that used to short-circuit:
GOOGLE_ADWORDS_OFFLINE_CONVERSIONSproduced no request in any fixture.run.jsneverloaded
test/setup.ts, which is how the component suite getsGOOGLE_ADS_DEVELOPER_TOKEN, soevery case 400'd in
getDeveloperTokenand the destination read as "builds no request" — thesame silent failure mode as the missing sandbox bundle the runner already guards against.
run.jsnow loads it.dataDeliveryfixtures gated a derivation that had no case torun.
SALESFORCE_OAUTHships a networkHandler and no transform, so it failed closed asharness-error— a defect reported about a destination that simply has nothing to derive from.The corpus scan now counts a bag only in a case
routeForaccepts, which is the same definitionthe derivation itself iterates by.
Nothing is masked wholesale. Getting there needed three changes beyond the derivation itself:
failing the destination closed. AWIN carries its declared
advertiserIdinside an unboundedparams.bd[N]family, one per product, which gjson/sjson cannot address; it derives["params"].Coarser than a leaf path — AWIN's amount and currency stop being visible — but strictly better
than the alternative it replaces, which masked the headers and body too.
substitution, because a decoy breaks the exchange rather than changing one value. They now
recover through the fetched-credential pass, which perturbs the mocked auth response instead,
and both derive
headers.Authorization.internal and not control-plane configurable, so neither holds customer credentials.
Known gaps
--validatereports rather than gates. A few fixture secrets are short or dual-use(
1234,dummy) and collide with ordinary data, giving 6 known false survivors. Gating needsdistinctive fixture values or a committed baseline.
exercises yields no path. Coverage currently runs
min 0, median 5cases per destination.URL instead of emitting it in
params, so it is masked nowhere. Fixable in those transformswith no change on the wire (both delivery paths merge
paramsinto the URL); recorded asendpointExposures: "query"rather than dropped silently.metadata.secretis treated as acredential because nothing declares which of its keys are, so non-credentials in the bag are
masked too.
TIKTOK_AUDIENCE'sadvertiser_idsis the visible case, nowbody.JSON.advertiser_ids.#. The cost is a less useful live event; the alternative is guessingat credential-looking key names, which fails in the direction that publishes a token.
independent of this tooling. Five destinations hold credential values that are too short,
identical to ordinary data in the same fixture, or spelled differently between cases
(
LEMNISK,FB_CUSTOM_AUDIENCE,EMARSYS,GA4,CLICKSEND); four destinations' paths reston a single fixture case;
ELOQUAdeclares a credential no fixture populates. That accounts forfive of the six
--validatesurvivors. The sixth,KLAVIYO, is not a fixture problem — itroutes
privateApiKeythroughmaskedSecrets.tscorrectly and its value is distinctive, so itssurvivor is a candidate real finding and should be triaged before
--validateis made to gate.18 of the 24 OAuth destinations derive their credential. The other six were each checked and
none is a gap:
BINGADS_AUDIENCEandYANDEX_METRICA_OFFLINE_EVENTSemit no headers and readno token;
BINGADS_OFFLINE_CONVERSIONSandSALESFORCE_BULK_UPLOADship no transform here andare absent from the manifest (already mask-everything by the contract);
SALESFORCE_OAUTHis anetworkHandler with no transform;
GAreads a token only in itsdeleteUsersflow, which neverrecords a destination live event.
config.auth.type === 'OAuth'looks like the authoritative answer to "is this destination handed a bag", butFACEBOOK_OFFLINE_CONVERSIONS,SALESFORCE,WOOTRICandYAHOO_DSPall readmetadata.secretwithout declaring OAuth, so gating on the registry would drop the source fordestinations that genuinely use it. The corpus errs the other way:
generateMetadataattaches asecretobject to every case it builds, so 59 destinations look like they have a bag. Adestination that never reads it derives nothing and still publishes
[], so no path is wrong —the cost is a derivation those destinations used to skip, and a
no-secret-locatedreason whereno-declared-secretsused to sit. Over-reporting costs a wasted derivation; under-reportingpublishes a token.
secretKeysdoes not declare, so the derivation correctly reports nothing to mask. This alsocovers destinations that name request fields from config (HTTP, WEBHOOK, PIPEDREAM), where a
workspace-chosen header is only masked if the config field it comes from is declared. These are
one-line fixes in
rudder-integrations-config, not here — the configured half follows theregistry rather than second-guessing it.
secretKeysmerge with masking consequences canturn an unrelated transformer PR red, and the manifest records no ref. The durable fix is to
record the resolved SHA in the manifest and have CI check out the ref the manifest names.
Review notes
A security review of this diff produced five findings; four are fixed here and the fifth is a
documented gap:
destinationscould be served, ordropped from the payload entirely. Now shape-validated, and the field is always present.
a distinct
no-definitionreason so the two stay countable.HTTPbuilds{ [config.apiKeyName]: config.apiKeyValue },WEBHOOKcopies user-configured header names)get the names their fixtures used, so a header a workspace names itself is not masked. Accepted
deliberately:
secretKeysis the source of truth, and the fix is to declare the config fieldupstream. Listed under Known gaps.
[]forno-declared-secrets/no-secret-locatedis by design, for the same reason — itdoes mean an undeclared credential is published as "nothing to mask".