Skip to content

fix(client): security hardening - #711

Merged
rodrigojara-cko merged 2 commits into
masterfrom
fix/INT-1785-security-hardening
Nov 20, 2026
Merged

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

Conversation

@rodrigojara-cko

@rodrigojara-cko rodrigojara-cko commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Security hardening of the OAuth client and of request logging: input validation of the
authorization URI and of the token response, and improved error handling of the token request.

Changes

  • src/main/java/com/checkout/OAuthSdkCredentials.java: security hardening of the token request and input validation
    of the authorization URI and of the token response; improved error handling: token request failures raise
    CheckoutAuthorizationException.
  • src/main/java/com/checkout/BaseUri.java: input validation of the authorization URI on the subdomain; authority
    helpers shared with the authorization URI validation.
  • src/main/java/com/checkout/EnvironmentSubdomain.java: documentation of the subdomain URIs.
  • src/main/java/com/checkout/CheckoutAuthorizationException.java: new constructor
    CheckoutAuthorizationException(String, Throwable); class and members documented.
  • src/main/java/com/checkout/ApacheHttpClientTransport.java: security hardening of request logging.
  • README.md: "Custom Environment" says which authorization URIs are accepted.

Design notes: the response headers written to the log come from a fixed allowlist (Cko-Request-Id, Cko-Version,
Content-Type, Content-Length, Date), so a header the SDK does not know is never logged; an allowlist is kept
instead of a blocklist because new headers are then left out by default. The authorization URI check reuses the
authority helpers of BaseUri (visible ASCII, host and port), so the URI with a subdomain and the URI without one
follow the same rules in one place. expires_in must be present and positive, and an expiration date that cannot be
computed is an invalid response; there is no upper limit, so any lifetime the token endpoint returns is kept.

API Reference

None.

Breaking changes

None in the public API (one constructor added). Behaviour changes, released as a minor version:

  • 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. Migration: use the https URI of
    the token endpoint, or a loopback host for a local mock server. Why it cannot stay compatible: the client
    credentials are sent to this URI, so this rule is the fix itself.
  • Input validation: some OAuth token responses now raise CheckoutAuthorizationException, among them three that
    were accepted before: a status other than 200 with a token in the body, an empty access_token and an expires_in
    that is not positive. Migration: none for the Checkout.com token endpoints. Why it cannot stay compatible: the token
    request fails closed on a response it cannot trust; the others carry no usable token and failed later with a less
    specific error.
  • Token request failures raise CheckoutAuthorizationException, a subclass of CheckoutException, also where a
    library or JDK exception was raised before (JsonSyntaxException, IllegalArgumentException,
    org.apache.http.ParseException, NullPointerException, DateTimeException, ArithmeticException). Migration:
    catch CheckoutException or CheckoutAuthorizationException. Why it cannot stay compatible: one SDK type for every
    invalid token response.
  • Request logging: the operation and response log lines hold less information. Migration: none, unless you parse
    these log lines. Why it cannot stay compatible: the information removed is what the fix keeps out of the logs.

Tests

  • Existing tests pass (./gradlew build javadoc)

  • Serialization tests cover every new or changed property (no request or response type changes)

  • README updated if documented usage changed

  • src/test/java/com/checkout/OAuthSdkCredentialsTokenRequestTest.java (new): authorization URI
    validation through the constructor, CustomEnvironment and the builder, and the token request
    against local servers.

  • src/test/java/com/checkout/ApacheHttpClientTransportLoggingTest.java (new): request logging.

  • src/test/java/com/checkout/OAuthSdkCredentialsTest.java and
    src/test/java/com/checkout/CheckoutSdkBuilderTest.java: https URIs and the new messages.

  • src/test/java/com/checkout/CheckoutSdkBaseUriTest.java: authorization URI validation on the subdomain.

Related

None.

@rodrigojara-cko
rodrigojara-cko requested a review from a team November 16, 2026 12:36
@agent-wall-e

agent-wall-e Bot commented Nov 16, 2026

Copy link
Copy Markdown

🔴 Risk Classification: MAJOR

Approval route: AI Review + Human Approval Required
Rollback controls: Change-freeze window + documented rollback plan

Classification reasons

  • security_sensitive_path:src/main/java/com/checkout/OAuthSdkCredentials.java
  • security_sensitive_path:src/test/java/com/checkout/OAuthSdkCredentialsTest.java
  • security_sensitive_path:src/test/java/com/checkout/OAuthSdkCredentialsTokenRequestTest.java

Operational gates

  • ✅ jira_ticket (INT-1785)
  • ✅ independent_review

Files analysed: 8


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
security_sensitive_path — src/main/java/com/checkout/OAuthSdkCredentials.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).
security_sensitive_path — src/test/java/com/checkout/OAuthSdkCredentialsTest.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).
security_sensitive_path — src/test/java/com/checkout/OAuthSdkCredentialsTokenRequestTest.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).

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

This comment has been minimized.

@rodrigojara-cko
rodrigojara-cko force-pushed the fix/INT-1785-security-hardening branch from 869e0eb to e699410 Compare November 19, 2026 10:59
@agent-wall-e

agent-wall-e Bot commented Nov 19, 2026

Copy link
Copy Markdown

🔴 Risk Classification: MAJOR

Approval route: AI Review + Human Approval Required
Rollback controls: Change-freeze window + documented rollback plan

Classification reasons

  • security_sensitive_path:src/main/java/com/checkout/OAuthSdkCredentials.java
  • security_sensitive_path:src/test/java/com/checkout/OAuthSdkCredentialsTest.java
  • security_sensitive_path:src/test/java/com/checkout/OAuthSdkCredentialsTokenRequestTest.java

Operational gates

  • ✅ jira_ticket (INT-1785)
  • ✅ independent_review

Files analysed: 8


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Nov 19, 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
security_sensitive_path — src/main/java/com/checkout/OAuthSdkCredentials.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).
security_sensitive_path — src/test/java/com/checkout/OAuthSdkCredentialsTest.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).
security_sensitive_path — src/test/java/com/checkout/OAuthSdkCredentialsTokenRequestTest.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).

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

@rodrigojara-cko
rodrigojara-cko force-pushed the fix/INT-1785-security-hardening branch from e699410 to b5a30f4 Compare November 19, 2026 18:24
@agent-wall-e

agent-wall-e Bot commented Nov 19, 2026

Copy link
Copy Markdown

🔴 Risk Classification: MAJOR

Approval route: AI Review + Human Approval Required
Rollback controls: Change-freeze window + documented rollback plan

Classification reasons

  • security_sensitive_path:src/main/java/com/checkout/OAuthSdkCredentials.java
  • security_sensitive_path:src/test/java/com/checkout/OAuthSdkCredentialsTest.java
  • security_sensitive_path:src/test/java/com/checkout/OAuthSdkCredentialsTokenRequestTest.java

Operational gates

  • ✅ jira_ticket (INT-1785)
  • ✅ independent_review

Files analysed: 11


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Nov 19, 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
security_sensitive_path — src/main/java/com/checkout/OAuthSdkCredentials.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).
security_sensitive_path — src/test/java/com/checkout/OAuthSdkCredentialsTest.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).
security_sensitive_path — src/test/java/com/checkout/OAuthSdkCredentialsTokenRequestTest.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).

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

@rodrigojara-cko

Copy link
Copy Markdown
Contributor Author

Thanks. Each point was checked against the branch; the valid ones are addressed in b5a30f4, the others need no change.

@agent-wall-e

agent-wall-e Bot commented Nov 20, 2026

Copy link
Copy Markdown

🔴 Risk Classification: MAJOR

Approval route: AI Review + Human Approval Required
Rollback controls: Change-freeze window + documented rollback plan

Classification reasons

  • security_sensitive_path:src/main/java/com/checkout/OAuthSdkCredentials.java
  • security_sensitive_path:src/test/java/com/checkout/OAuthSdkCredentialsTest.java
  • security_sensitive_path:src/test/java/com/checkout/OAuthSdkCredentialsTokenRequestTest.java

Operational gates

  • ✅ jira_ticket (INT-1785)
  • ✅ independent_review

Files analysed: 11


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Nov 20, 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
security_sensitive_path — src/main/java/com/checkout/OAuthSdkCredentials.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).
security_sensitive_path — src/test/java/com/checkout/OAuthSdkCredentialsTest.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).
security_sensitive_path — src/test/java/com/checkout/OAuthSdkCredentialsTokenRequestTest.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).

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

Security hardening and input validation in the OAuth client and in
request logging.
@armando-rodriguez-cko
armando-rodriguez-cko force-pushed the fix/INT-1785-security-hardening branch from d532c12 to 32b5ae9 Compare November 20, 2026 13:11
@agent-wall-e

agent-wall-e Bot commented Nov 20, 2026

Copy link
Copy Markdown

🔴 Risk Classification: MAJOR

Approval route: AI Review + Human Approval Required
Rollback controls: Change-freeze window + documented rollback plan

Classification reasons

  • security_sensitive_path:src/main/java/com/checkout/OAuthSdkCredentials.java
  • security_sensitive_path:src/test/java/com/checkout/OAuthSdkCredentialsTest.java
  • security_sensitive_path:src/test/java/com/checkout/OAuthSdkCredentialsTokenRequestTest.java

Operational gates

  • ✅ jira_ticket (INT-1785)
  • ✅ independent_review

Files analysed: 11


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Nov 20, 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
security_sensitive_path — src/main/java/com/checkout/OAuthSdkCredentials.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).
security_sensitive_path — src/test/java/com/checkout/OAuthSdkCredentialsTest.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).
security_sensitive_path — src/test/java/com/checkout/OAuthSdkCredentialsTokenRequestTest.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).

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

@rodrigojara-cko
rodrigojara-cko merged commit 20d0b4f into master Nov 20, 2026
6 checks passed
@rodrigojara-cko
rodrigojara-cko deleted the fix/INT-1785-security-hardening branch November 20, 2026 14:16
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