Skip to content

fix(client): security hardening - #489

Merged
rodrigojara-cko merged 2 commits into
masterfrom
fix/INT-1898-security-hardening
Dec 4, 2026
Merged

rodrigojara-cko merged 2 commits into
masterfrom
fix/INT-1898-security-hardening

Conversation

@rodrigojara-cko

@rodrigojara-cko rodrigojara-cko commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Security hardening of the request headers, and an explicit ifMatch parameter for the payment instrument update.

Changes

  • src/services/http.js: security hardening of the request headers, on both HTTP clients.
  • src/services/utils.js: setHeader, which sets a header as the only one of its name.
  • src/api/platforms/payment-instruments.js, src/api/platforms/platforms.js: updatePaymentInstrumentDetails(entityId, id, body, ifMatch) sends ifMatch as the only If-Match header, replacing a configured one; it is not sent when undefined or null, and then a runtime warning is emitted if body.headers still holds an if-match key.
  • types/dist/api/platforms/payment-instruments.d.ts, types/dist/api/platforms/platforms.d.ts: the ifMatch parameter, the label and default docs from the API reference, and headers removed from UpdatePaymentInstrumentRequest.
  • test/http/requestHeaders.js: request headers on both HTTP clients (fetch and axios), and the payment instrument update with ifMatch, OAuth included.
  • test/platforms/payment-instruments/payment-instruments-unit.js: the update passes the ETag in ifMatch.

Design notes: setHeader is used only for the headers the SDK sets (Authorization, Content-Type, Cko-Idempotency-Key, and If-Match from ifMatch), so a configured header of the same name is replaced instead of sent next to the SDK value; names are compared as the HTTP clients compare them. The configured header objects are copied for each request, so the merchant's configuration object is not changed. A configured Cko-Idempotency-Key is still sent when no idempotency key is passed. ifMatch follows updateReserveRule (same parameter position, sent through the configuration headers). The warning uses process.emitWarning, so JavaScript callers of the earlier form learn about the change at runtime instead of only through the 428; the key is only detected, never sent as a header. No new validation or error type: a value the HTTP client cannot send is handled by the client as before (fetch rejects it with the SDK's ApiError).

API Reference

Breaking changes

Released as a minor version (security hardening).

  • A headers field in a request body is no longer sent as HTTP headers; it is sent only inside the body. Migration: use the method parameter where there is one, otherwise options.headers.
  • updatePaymentInstrumentDetails: the ETag is no longer read from body.headers['if-match'], and in TypeScript ifMatch is a required parameter. The API reads the ETag only from the If-Match header and answers 428 without it. Migration: updatePaymentInstrumentDetails(entityId, id, body, ifMatch); a call that still passes the ETag in body.headers emits a runtime warning.
  • A configured Authorization, Content-Type or Cko-Idempotency-Key no longer replaces or is sent next to the SDK value, on fetch and on axios. Migration: none needed; pass the idempotency key as the method parameter.

Tests

  • Existing tests pass
  • Serialization tests cover every new or changed property
  • README updated if documented usage changed

Unit and integration suites green. The integration test test/http/httpClient-it.js (axios timeout) is intermittent on master too: it can stop the run with an uncaught connection error, and under act the build workflow passed or stopped there depending on the run. It is unrelated to this change.

Related

None.

@agent-wall-e

agent-wall-e Bot commented Dec 3, 2026

Copy link
Copy Markdown

🟡 Risk Classification: MINOR

Approval route: AI Review + Human Approval
Rollback controls: Staged rollout + rollback

Classification reasons

  • no_low_class_matched
  • prod_source_modified

Operational gates

  • ✅ jira_ticket (INT-1898)
  • ✅ independent_review

Files analysed: 8


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Dec 3, 2026

Copy link
Copy Markdown
🔬 Debug — why this classification?

Each reason code emitted by the classifier, its source clause in the AI in SDLC Control Framework, and what it means.

Reason code Kind Clause Meaning
no_low_class_matched informational §2.2 (fall-through) None of the deterministic Low classes (§2.2.3, §2.2.4, §2.2.7, docs-only) applied; classifier fell through to LLM evaluation.
prod_source_modified informational §2.1 M7 (informational) At least one file is non-doc, non-test, non-IaC — i.e. application source code was modified.

Kinds:

  • classifying — this rule contributed to the chosen tier.
  • informational — context only; did not by itself decide the tier.

See issue #3 for the proposal to formalise this map as Appendix A of the standards doc.

wall-e 2026.06.19-02 · debug

@agent-wall-e

agent-wall-e Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

🟠 Advisory review: Concerns worth a look

This PR needs a human approval. Before you give it, these are the things I'd want resolved.

This PR hardens request header handling and adds an explicit ifMatch parameter to updatePaymentInstrumentDetails. The logic is largely sound, but there are a few concrete issues worth resolving before approval.

Concerns

  • In setHeader, the filter uses key.trim().toLowerCase() === lowerName but lowerName is derived from name.toLowerCase() without trimming — so a configured header ' Authorization' (leading space) would be trimmed to 'authorization' and deleted, but the name passed as name (e.g. 'Authorization') would not match if it had no trim applied to lowerName. This is intentional per the test cases (' Authorization' should be replaced), but the asymmetry means the trim is only applied to existing keys, not to name itself. If name were ever passed with surrounding whitespace the new header would be inserted without removing the old one — low risk given internal callers, but worth confirming name is always trimmed at call sites.
  • In withoutNamesInGroups the names array uses toLowerCase() for comparison but the entries from headers[key] are filtered with name.trim().toLowerCase() — the trim is applied to group-entry keys but not to the names elements being compared against. This is consistent with internal call sites passing clean lowercase names, but the asymmetry is a subtle footgun if the function is ever reused.
  • AXIOS_HEADER_GROUPS is exported from src/services/http.js and imported in the test to validate it matches axios's internal methodList. The list in the diff includes 'query' and 'purge'/'link'/'unlink' — these are non-standard axios extensions and the test correctly guards against drift via methodList, but if the axios version is upgraded without updating AXIOS_HEADER_GROUPS the security property silently regresses; there is no runtime assertion in production code.
  • The ifMatch parameter is typed as string (non-optional) in both .d.ts files, but the implementation explicitly handles undefined and null with a warning path. The TypeScript signature should be ifMatch?: string or ifMatch: string | undefined | null to match the runtime contract and avoid a type error for callers that intentionally omit it.
  • The warning via process.emitWarning fires only when ifMatch is falsy AND body.headers contains an if-match key — callers who simply omit ifMatch without putting it in body.headers get no warning and silently receive a 428 from the API. This is a known design choice per the PR description, but reviewers should confirm it is acceptable UX.
  • The diff is truncated (test file cut off mid-way); the full coverage of axios header-group stripping and the OAuth flow tests cannot be fully verified from what is shown.

⚠️ The diff was too large to read in full, so this review covers only part of the change.


This is not an approval. wall-e cannot auto-approve this PR — it is an opinion to help whoever does. Advisory review · us.anthropic.claude-sonnet-4-6 · wall-e 2026.06.19-02

@agent-wall-e

agent-wall-e Bot commented Dec 3, 2026

Copy link
Copy Markdown

🟡 Risk Classification: MINOR

Approval route: AI Review + Human Approval
Rollback controls: Staged rollout + rollback

Classification reasons

  • no_low_class_matched
  • prod_source_modified

Operational gates

  • ✅ jira_ticket (INT-1898)
  • ✅ independent_review

Files analysed: 8


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Dec 3, 2026

Copy link
Copy Markdown
🔬 Debug — why this classification?

Each reason code emitted by the classifier, its source clause in the AI in SDLC Control Framework, and what it means.

Reason code Kind Clause Meaning
no_low_class_matched informational §2.2 (fall-through) None of the deterministic Low classes (§2.2.3, §2.2.4, §2.2.7, docs-only) applied; classifier fell through to LLM evaluation.
prod_source_modified informational §2.1 M7 (informational) At least one file is non-doc, non-test, non-IaC — i.e. application source code was modified.

Kinds:

  • classifying — this rule contributed to the chosen tier.
  • informational — context only; did not by itself decide the tier.

See issue #3 for the proposal to formalise this map as Appendix A of the standards doc.

wall-e 2026.06.19-02 · debug

david-ruiz-cko
david-ruiz-cko previously approved these changes Dec 4, 2026
Security hardening of the request headers, on fetch and on axios.

updatePaymentInstrumentDetails takes the ETag as an explicit ifMatch
parameter, sent as the If-Match header and not sent when undefined or
null.
updatePaymentInstrumentDetails emits a runtime warning when ifMatch is
not given and body.headers holds an if-match key, the form earlier
versions read the ETag from. The key is still sent only inside the body.

The types and the method docs describe label, default and ifMatch as in
the API reference, and the header group list is exported for its test.
@agent-wall-e

agent-wall-e Bot commented Dec 4, 2026

Copy link
Copy Markdown

🟡 Risk Classification: MINOR

Approval route: AI Review + Human Approval
Rollback controls: Staged rollout + rollback

Classification reasons

  • no_low_class_matched
  • prod_source_modified

Operational gates

  • ✅ jira_ticket (INT-1898)
  • ✅ independent_review

Files analysed: 8


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Dec 4, 2026

Copy link
Copy Markdown
🔬 Debug — why this classification?

Each reason code emitted by the classifier, its source clause in the AI in SDLC Control Framework, and what it means.

Reason code Kind Clause Meaning
no_low_class_matched informational §2.2 (fall-through) None of the deterministic Low classes (§2.2.3, §2.2.4, §2.2.7, docs-only) applied; classifier fell through to LLM evaluation.
prod_source_modified informational §2.1 M7 (informational) At least one file is non-doc, non-test, non-IaC — i.e. application source code was modified.

Kinds:

  • classifying — this rule contributed to the chosen tier.
  • informational — context only; did not by itself decide the tier.

See issue #3 for the proposal to formalise this map as Appendix A of the standards doc.

wall-e 2026.06.19-02 · debug

@sonarqubecloud

sonarqubecloud Bot commented Dec 4, 2026

Copy link
Copy Markdown

@rodrigojara-cko
rodrigojara-cko merged commit 9137630 into master Dec 4, 2026
6 checks passed
@rodrigojara-cko
rodrigojara-cko deleted the fix/INT-1898-security-hardening branch December 4, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants