Skip to content

feat(secret-paths): derive and serve the request paths to mask per destination - #5595

Closed
shekhar-rudder wants to merge 5 commits into
developfrom
feat/secret-paths-manifest
Closed

shekhar-rudder wants to merge 5 commits into
developfrom
feat/secret-paths-manifest

Conversation

@shekhar-rudder

@shekhar-rudder shekhar-rudder commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

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 /features as secretPaths, so the data plane can mask those fields before the payload is
shown.

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:

  • Configured — secretKeys from the destination definition, the source of truth for which
    config fields are credentials. Perturbed by name, wherever that key appears in a config.
  • Runtime — the metadata.secret bag the control plane mints per OAuth account and
    rudder-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 secretKeys cannot describe it. An OAuth destination's bearer
token is never a config field — GOOGLE_ADWORDS_ENHANCED_CONVERSIONS declares secretKeys: []
and still sends Authorization: Bearer <token>, plus the same token again in
params.accessToken — so following the registry alone published "nothing to mask" for all 24
OAuth 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:

  • Corroboration. Each key is substituted with two different decoys. A field that merely
    broke as a side effect collapses to the same value both times and is rejected.
  • Shape stability. If a decoy changes the number of requests or fields, the transform took a
    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_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>"; excluded from the
diff, 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 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.

The contract

destType -> string[] | null, with exactly three cases: a list of paths, [] for nothing to
mask, and null for mask-everything. A destType absent from the map is the same case as null.

null rather than a sentinel path like ["*"] on purpose: the fail-closed case is the absence
of 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 — masking
nothing 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 secretKeys declares an identifier
sitting in the host or path. The generator classifies rather than silently drops the ones that
do carry a credential, recording them in endpointExposures: url where the URL is the shared
secret, and query where a parameter that belongs in params was concatenated into the endpoint
string instead. See Known gaps.

Staying in sync

  • npm run secret-paths: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 plus the same secretKeys produce the
    same bytes everywhere. Keys are sorted on emit, and the file is in .prettierignore so lint
    cannot reformat what the generator just wrote. Runs per PR via .github/workflows/secret-paths.yml.
  • npm run secret-paths:validate replays the corpus against the committed paths and reports any
    declared secret that survives masking, plus how many fixture cases back each entry.

The loader refuses a manifest it cannot vouch for — wrong version, or destinations not a map of
string-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:

destType was now
GOOGLE_ADWORDS_ENHANCED_CONVERSIONS [] headers.Authorization, params.accessToken
GOOGLE_ADWORDS_OFFLINE_CONVERSIONS [] headers.Authorization
GOOGLE_ADWORDS_REMARKETING_LISTS [] headers.Authorization
AMAZON_AUDIENCE [] headers.Amazon-Advertising-API-ClientId, headers.Authorization
CAMPAIGN_MANAGER, CRITEO_AUDIENCE, INTERCOM_V2, LINKEDIN_ADS, LINKEDIN_AUDIENCE, REDDIT, REDDIT_AUDIENCE, TWITTER_ADS, X_AUDIENCE, ZOHO [] headers.Authorization
TIKTOK_AUDIENCE [] body.JSON.advertiser_ids.#, headers.Access-Token
PARDOT headers.Pardot-Business-Unit-Id + headers.Authorization
SNAPCHAT_CUSTOM_AUDIENCE body.JSON.users.#.id + headers.Authorization

No destination's list shrank, and none became fail-closed. SALESFORCE additionally picks up an
endpointExposures: "url" entry: its bag carries instanceUrl, which lands in the endpoint, and
the endpoint is excluded from masking by decision.

Two bugs surfaced by running the derivation over destinations that used to short-circuit:

  • 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.
    run.js now loads it.
  • 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, which is the same definition
    the derivation itself iterates by.

Nothing is masked wholesale. Getting there needed three changes beyond the derivation itself:

  • A dynamically-numbered key family now collapses to the object containing it rather than
    failing the destination closed. AWIN carries its declared advertiserId inside an unbounded
    params.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.
  • Destinations that trade a credential for a session token (SFMC, MARKETO) destabilise under
    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.
  • No destination definition maps to "nothing to mask" rather than fail-closed. Both cases are
    internal and not control-plane configurable, so neither holds customer credentials.

Known gaps

  • --validate reports 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 needs
    distinctive fixture values or a committed baseline.
  • Coverage is bounded by the fixture corpus. A credential-carrying branch that no fixture
    exercises yields no path. Coverage currently runs min 0, median 5 cases per destination.
  • Query-parameter credentials in the endpoint. Four destinations concatenate a token into the
    URL instead of emitting it in params, so it is masked nowhere. Fixable in those transforms
    with no change on the wire (both delivery paths merge params into the URL); recorded as
    endpointExposures: "query" rather than dropped silently.
  • Over-masking is accepted, by decision. Everything under metadata.secret is treated as a
    credential because nothing declares which of its keys are, so non-credentials in the bag are
    masked too. TIKTOK_AUDIENCE's advertiser_ids is the visible case, now
    body.JSON.advertiser_ids.#. The cost is a less useful live event; the alternative is guessing
    at credential-looking key names, which fails in the direction that publishes a token.
  • Fixture quality bounds what can be concluded, tracked in INT-7221 — fixture-only work,
    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 rest
    on a single fixture case; ELOQUA declares a credential no fixture populates. That accounts for
    five of the six --validate survivors. The sixth, KLAVIYO, is not a fixture problem — it
    routes privateApiKey through maskedSecrets.ts correctly and its value is distinctive, so its
    survivor is a candidate real finding and should be triaged before --validate is made to gate.
    18 of the 24 OAuth destinations derive their credential. The other six were each checked and
    none is a gap: BINGADS_AUDIENCE and YANDEX_METRICA_OFFLINE_EVENTS emit no headers and read
    no token; BINGADS_OFFLINE_CONVERSIONS and SALESFORCE_BULK_UPLOAD ship no transform here and
    are absent from the manifest (already mask-everything by the contract); SALESFORCE_OAUTH is a
    networkHandler with no transform; GA reads a token only in its deleteUsers flow, which never
    records a destination live event.
  • Discovery is corpus-based, not registry-based, and that is deliberate. config.auth.type === 'OAuth' looks like the authoritative answer to "is this destination handed a bag", but
    FACEBOOK_OFFLINE_CONVERSIONS, SALESFORCE, WOOTRIC and YAHOO_DSP all read
    metadata.secret without declaring OAuth, so gating on the registry would drop the source for
    destinations that genuinely use it. The corpus errs the other way: generateMetadata attaches a
    secret object to every case it builds, so 59 destinations look like they have a bag. A
    destination 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-located reason where
    no-declared-secrets used to sit. Over-reporting costs a wasted derivation; under-reporting
    publishes a token.
  • Undeclared config credentials. Several destinations send a config credential that
    secretKeys does not declare, so the derivation correctly reports nothing to mask. This also
    covers 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 the
    registry rather than second-guessing it.
  • The upstream ref is a branch, not a pin. A secretKeys merge with masking consequences can
    turn 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:

  • The loader validated only the version, so a malformed destinations could be served, or
    dropped from the payload entirely. Now shape-validated, and the field is always present.
  • A missing destination definition was indistinguishable from one declaring no secrets. Now
    a distinct no-definition reason so the two stay countable.
  • Destinations that take request field names from config (HTTP builds
    { [config.apiKeyName]: config.apiKeyValue }, WEBHOOK copies user-configured header names)
    get the names their fixtures used, so a header a workspace names itself is not masked. Accepted
    deliberately: secretKeys is the source of truth, and the fix is to declare the config field
    upstream. Listed under Known gaps.
  • [] for no-declared-secrets / no-secret-located is by design, for the same reason — it
    does mean an undeclared credential is published as "nothing to mask".

@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: e1fd213a-020c-4980-b837-a2c7d8f1b2db

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.44444% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.00%. Comparing base (764eeaf) to head (bd2b054).

Files with missing lines Patch % Lines
src/secretPaths/index.ts 66.66% 7 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@shekhar-rudder
shekhar-rudder force-pushed the feat/secret-paths-manifest branch from 15650c8 to 57617a2 Compare September 21, 2026 10:12
…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.
@shekhar-rudder
shekhar-rudder force-pushed the feat/secret-paths-manifest branch from 57617a2 to e7f93e2 Compare September 21, 2026 10:29
shekhar-rudder and others added 4 commits September 24, 2026 14:46
… 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]>
@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant