Skip to content

fix(client): security hardening - #709

Merged
armando-rodriguez-cko merged 7 commits into
masterfrom
fix/INT-1777-security-hardening
Nov 18, 2026
Merged

armando-rodriguez-cko merged 7 commits into
masterfrom
fix/INT-1777-security-hardening

Conversation

@armando-rodriguez-cko

@armando-rodriguez-cko armando-rodriguez-cko commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Security hardening of request building and the HTTP transport: input validation for path parameters, the final request URL and the configured base URIs.

Changes

  • AbstractClient: path parameters that cannot be sent as exactly one segment are refused with a CheckoutArgumentException before any request is sent.
  • ApacheHttpClientTransport: input validation of the final request path and query; each base URI goes through BaseUri when the client is created.
  • BaseUri (new, package-private): base URI validation and the environment subdomain rebuild, one place for both; errors name the setting, never its value.
  • EnvironmentSubdomain: checkoutApi is validated with the same rules before the subdomain is added; the rebuilt URIs keep the path, query and fragment without decoding (checkoutApi after normalising) and host names with "_" keep working.
  • ApiClientImpl, CheckoutApiImpl, AbstractCheckoutApmApi: pass the name of the base URI setting (checkoutApi, filesApi, transfersApi, balancesApi, forwardApi, identityApi) to the transport for its errors.
  • UriCharacters (new, package-private): one helper for the path and query character rules, used by AbstractClient, the transport and BaseUri.
  • CustomersClient: Javadoc on every method; get and getSync document which identifiers are accepted.
  • README.md: the Custom Environment section lists every URI setting, says each one is needed when the SDK is built and how a base URI with a path must end. The base URI rules apply to the six API settings; oAuthAuthorizationApi keeps its current handling (only its host is checked with environmentSubdomain).
  • Tests: CheckoutSdkBaseUriTest (new, public builder with a recording HTTP client), UriCharactersTest (new), ApacheHttpClientTransportRequestUrlTest and AbstractClientBuildPathTest extended, RecordingHttpClientBuilder (new test helper).

API Reference

Breaking changes

  • Path values that cannot be sent as one path segment are now refused with a CheckoutArgumentException before the request is sent. CustomersClient.get / getSync with an email containing "/" or "": pass the customer's ID instead.
  • Custom base URIs (CustomEnvironment, or a custom UriStrategy given to ApiClientImpl) are validated when the SDK is built, every setting included, also ones never called. An invalid one now fails build() with a CheckoutArgumentException that names the setting. With environmentSubdomain, checkoutApi gets the same validation and its host, like the host of oAuthAuthorizationApi, must be a domain name. Migration: give each setting an absolute http or https URI with a host, as described in the README Custom Environment section, ending with "/" when it has a path.

Both are minor (security hardening). Built-in environments and valid identifiers are unchanged on the wire.

Tests

  • Existing tests pass
  • Serialization tests cover every new or changed property (N/A: no model changed)
  • README updated if documented usage changed

Related

None.

Follow-up hardening in request building and the HTTP transport. Reported internally.
@armando-rodriguez-cko
armando-rodriguez-cko requested a review from a team November 13, 2026 13:00
@agent-wall-e

agent-wall-e Bot commented Nov 13, 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-1777)
  • ✅ independent_review

Files analysed: 4


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Nov 13, 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 Nov 13, 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 adds input validation for path parameters, base URIs, and the HTTP transport — the logic reads as correct and the test coverage is extensive, but several concrete issues need resolution before approval.

Concerns

  • AbstractClientBuildPathTest removes test cases that previously verified '/' and '\' were percent-encoded (e.g. 'pay_1/refunds' → 'payments/pay_1%2Frefunds') and replaces them with refusal; this is a breaking change for any caller using an email as a customer identifier, and the test removal confirms the old behavior is intentionally dropped — the reviewer must confirm this breaking change is acceptable and communicated.
  • README.md paragraph wrapping is broken: 'With environmentSubdomain, the hosts of checkoutApi and oAuthAuthorizationApi must be domain names...' runs on without a line break from the preceding sentence, making the published documentation hard to read and potentially confusing.
  • The README now states 'set checkoutApi, filesApi, transfersApi, balancesApi, forwardApi and identityApi, also for the modules you do not call' — this is a breaking change in behavior (previously only needed URIs were required); the PR description calls this a migration requirement but the README does not explain what happens if one is omitted (a CheckoutArgumentException at build() time), which may surprise users who don't call certain modules.
  • BaseUri.normalise() calls baseUri.normalize() (Java's URI normalisation) on a URI that already passed the dot-segment check on the raw path; this means the validation and the normalised result could differ if normalize() collapses something the segment-by-segment check missed — the segments are checked on the already-normalised URI so this appears safe, but the two-step logic (normalize then check) is fragile and deserves an explicit test for a URI like 'https://proxy.example/a/b/../c/'.
  • BaseUri.withSubdomain() copies getRawQuery() and getRawFragment() from the input URI without validation; since oAuthAuthorizationApi skips normalise(), a crafted oAuthAuthorizationApi URI with a fragment or unusual query could produce a surprising rebuilt URI — this is lower severity but inconsistent with the strict validation applied to the other six settings.
  • getRequestUrl() was changed from package-private to private, removing it from the existing test surface; the tests now go through invokeSync via RecordingHttpClientBuilder, which is better end-to-end coverage, but any future unit tests for URL construction will need the full transport stack.
  • UriCharacters.isPercentEncoded() returns false for an empty string, and the query validation path in validateRequestPath passes the substring after '?' to it — a URL ending in '?' (empty query) will be refused; this may or may not be the intended behavior but is not explicitly tested.
  • RecordingHttpClientBuilder.doExecute() casts the HttpRequest argument to HttpUriRequest without a check; if Apache HttpClient ever calls doExecute with a plain HttpRequest (e.g. in a proxied request), this will throw a ClassCastException at test time — low risk but worth a defensive instanceof check.

⚠️ 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 Nov 16, 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-1777)
  • ✅ independent_review

Files analysed: 4


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Nov 16, 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 Nov 16, 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-1777)
  • ✅ independent_review

Files analysed: 4


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Nov 16, 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

Input validation for request paths and base URIs.

- Path parameters that cannot be sent as exactly one path segment are
  refused with a CheckoutArgumentException before any request is sent.
- The transport checks the final request path and query, and validates
  each base URI when the SDK is built; the error names the setting
  (for example filesApi), never its value. The environment subdomain
  is added after the same validation, without decoding the URI.
- Path and query character rules live in one shared helper.
- CustomersClient documents which identifiers GET /customers/{identifier}
  accepts; the README lists every base URI setting and its format.

Valid identifiers are sent exactly as before.
@agent-wall-e

agent-wall-e Bot commented Nov 17, 2026

Copy link
Copy Markdown

🟡 Risk Classification: MINOR

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

Classification reasons

  • exceeds_bounded_scope:481>250

Operational gates

  • ✅ jira_ticket (INT-1777)
  • ✅ independent_review

Files analysed: 16


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Nov 17, 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
exceeds_bounded_scope — 481>250 classifying §2.1 M8 More than 250 non-test, non-doc, non-lockfile lines changed.

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

- Base URIs are refused when their host is not ASCII.
- README Custom Environment: which settings the base URI rules cover,
  the OAuth token URI, and that a query or fragment is not sent.
- Javadoc of the environment subdomain describes the normalised URI.
@agent-wall-e

agent-wall-e Bot commented Nov 18, 2026

Copy link
Copy Markdown

🟡 Risk Classification: MINOR

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

Classification reasons

  • exceeds_bounded_scope:493>250

Operational gates

  • ✅ jira_ticket (INT-1777)
  • ✅ independent_review

Files analysed: 16


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Nov 18, 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
exceeds_bounded_scope — 493>250 classifying §2.1 M8 More than 250 non-test, non-doc, non-lockfile lines changed.

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 Nov 18, 2026
@agent-wall-e

agent-wall-e Bot commented Nov 18, 2026

Copy link
Copy Markdown

🟡 Risk Classification: MINOR

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

Classification reasons

  • exceeds_bounded_scope:493>250

Operational gates

  • ✅ jira_ticket (INT-1777)
  • ✅ independent_review

Files analysed: 16


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Nov 18, 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
exceeds_bounded_scope — 493>250 classifying §2.1 M8 More than 250 non-test, non-doc, non-lockfile lines changed.

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

Copy link
Copy Markdown

@armando-rodriguez-cko
armando-rodriguez-cko merged commit 9ad3623 into master Nov 18, 2026
6 checks passed
@armando-rodriguez-cko
armando-rodriguez-cko deleted the fix/INT-1777-security-hardening branch November 18, 2026 14:19
armando-rodriguez-cko pushed a commit that referenced this pull request Nov 20, 2026
This release brings security hardening of request building, the OAuth client and request logging, and fixes responses that repeat a header. Custom base URIs and the OAuth authorization URI are now validated when the SDK is built, so check them before upgrading if you set them. No public member is removed; one constructor is added.

**Added**

* `CheckoutAuthorizationException(String, Throwable)` (#711).

**Changed**

* Security hardening (#707, #709, #711).
* Path values that cannot be sent as one path segment (null, empty, `.`, `..`, or containing "/" or "\") raise `CheckoutArgumentException` before the request is sent. For `CustomersClient#get` with an email that contains "/" or "\", pass the customer ID instead (#707, #709).
* Custom base URIs (`CustomEnvironment`, or a custom `UriStrategy` given to `ApiClientImpl`) are validated when the SDK is built, every setting included. An invalid one fails `build()` with a `CheckoutArgumentException` that names the setting. Use absolute `http` or `https` URIs with a host, ending with "/" when they have a path, as described in the README Custom Environment section (#709).
* The OAuth authorization URI must be an absolute `https` URI with an ASCII host written without percent-encoding, no user information and an optional port from 1 to 65535; `http` is accepted only for `localhost`, `127.0.0.0/8` and `[::1]`. Any other URI throws `CheckoutArgumentException` when the SDK is built (#711).
* OAuth token request failures and token responses that cannot be used raise `CheckoutAuthorizationException`, a subclass of `CheckoutException`. Catch `CheckoutException` or `CheckoutAuthorizationException` (#711).
* The request and response log lines hold less information (#711).

**Fixed**

* A response that repeats a header (for example two `Set-Cookie` headers) is no longer reported as a 400; the first value is kept (#713).
* With a custom base URI that has a path, iDEAL requests stay under that path like every other request (#707).
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.

3 participants