Skip to content

[release-ocm-2.15] ACM-31978: CVE-2026-32286 Upgrade PostgreSQL stack to pgx v5#10597

Open
shay23bra wants to merge 2 commits into
openshift:release-ocm-2.15from
shay23bra:pgx-v5-migration-release-ocm-2.15
Open

[release-ocm-2.15] ACM-31978: CVE-2026-32286 Upgrade PostgreSQL stack to pgx v5#10597
shay23bra wants to merge 2 commits into
openshift:release-ocm-2.15from
shay23bra:pgx-v5-migration-release-ocm-2.15

Conversation

@shay23bra

@shay23bra shay23bra commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Backport of PR #10230 — upgrade PostgreSQL stack from pgx v4 to pgx v5.

Removes the deprecated github.com/jackc/pgproto3/v2 module which has unpatched CVEs.

CVEs resolved

  • CVE-2026-32286 — pgproto3/v2: Denial of Service via malicious PostgreSQL server
  • CVE-2026-4427 — pgproto3/v2: Denial of Service (same module)

Strategy Selection

✓ Successful Strategy: Cherry-pick from master

Cherry-picked commit 420ef6b (MGMT-19930: upgrade PostgreSQL stack to pgx v5 and ocm-sdk-go v0.1.499) from master.

https://redhat.atlassian.net/browse/ACM-31978

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 6, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 6, 2026

Copy link
Copy Markdown

@shay23bra: This pull request references ACM-31978 which is a valid jira issue.

Details

In response to this:

Backport of PR #10230 — upgrade PostgreSQL stack from pgx v4 to pgx v5.

Removes the deprecated github.com/jackc/pgproto3/v2 module which has unpatched CVEs.

CVEs resolved

  • CVE-2026-32286 — pgproto3/v2: Denial of Service via malicious PostgreSQL server
  • CVE-2026-4427 — pgproto3/v2: Denial of Service (same module)

Strategy Selection

✓ Successful Strategy: Cherry-pick from master

Cherry-picked commit 420ef6b (MGMT-19930: upgrade PostgreSQL stack to pgx v5 and ocm-sdk-go v0.1.499) from master.

https://redhat.atlassian.net/browse/ACM-31978


This PR was automatically generated by the CVE Automation tool.
For questions or issues, reach out in #cve-automation.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 1a4f7258-40ce-43bd-99fd-86f63a5dae91

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci openshift-ci Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 6, 2026
@openshift-ci openshift-ci Bot requested review from gamli75 and oourfali July 6, 2026 14:27
@openshift-ci openshift-ci Bot added the api-review Categorizes an issue or PR as actively needing an API review. label Jul 6, 2026
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 43.64%. Comparing base (d931df0) to head (5ab1398).

Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                  @@
##           release-ocm-2.15   #10597      +/-   ##
====================================================
- Coverage             43.66%   43.64%   -0.02%     
====================================================
  Files                   407      408       +1     
  Lines                 70611    70640      +29     
====================================================
  Hits                  30832    30832              
- Misses                36999    37028      +29     
  Partials               2780     2780              
Files with missing lines Coverage Δ
cmd/main.go 0.00% <ø> (ø)
internal/bminventory/inventory.go 72.04% <ø> (ø)
internal/cluster/cluster.go 67.61% <ø> (+0.02%) ⬆️
internal/common/common_unitest_db.go 23.04% <ø> (-0.34%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gamli75

gamli75 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

/test subsystem-aws

1 similar comment
@gamli75

gamli75 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

/test subsystem-aws

@shay23bra

Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@shay23bra

Copy link
Copy Markdown
Contributor Author

/retest

@gamli75

gamli75 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

/approve

@openshift-ci

openshift-ci Bot commented Jul 14, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gamli75, shay23bra

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 14, 2026
@shay23bra

Copy link
Copy Markdown
Contributor Author

/retest

@gamli75

gamli75 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 14, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-ai-operator-ztp-3masters

@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 14, 2026
@shay23bra shay23bra force-pushed the pgx-v5-migration-release-ocm-2.15 branch from 7401536 to dfabc69 Compare July 14, 2026 14:08
@openshift-ci openshift-ci Bot removed lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jul 14, 2026
@gamli75

gamli75 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

/override ci/prow/e2e-ai-operator-ztp-3masters

1 similar comment
@gamli75

gamli75 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

/override ci/prow/e2e-ai-operator-ztp-3masters

@gamli75

gamli75 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci

openshift-ci Bot commented Jul 14, 2026

Copy link
Copy Markdown

@gamli75: Overrode contexts on behalf of gamli75: ci/prow/e2e-ai-operator-ztp-3masters

Details

In response to this:

/override ci/prow/e2e-ai-operator-ztp-3masters

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 14, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-ai-operator-ztp-3masters

@openshift-ci

openshift-ci Bot commented Jul 14, 2026

Copy link
Copy Markdown

@gamli75: Overrode contexts on behalf of gamli75: ci/prow/e2e-ai-operator-ztp-3masters

Details

In response to this:

/override ci/prow/e2e-ai-operator-ztp-3masters

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@gamli75

gamli75 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

/override ci/prow/e2e-ai-operator-disconnected-capi

@openshift-ci

openshift-ci Bot commented Jul 14, 2026

Copy link
Copy Markdown

@gamli75: Overrode contexts on behalf of gamli75: ci/prow/e2e-ai-operator-disconnected-capi

Details

In response to this:

/override ci/prow/e2e-ai-operator-disconnected-capi

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD 098c1b6 and 2 for PR HEAD dfabc69 in total

@gamli75

gamli75 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

/override ci/prow/e2e-ai-operator-ztp-3masters

@openshift-ci

openshift-ci Bot commented Jul 14, 2026

Copy link
Copy Markdown

@gamli75: Overrode contexts on behalf of gamli75: ci/prow/e2e-ai-operator-ztp-3masters

Details

In response to this:

/override ci/prow/e2e-ai-operator-ztp-3masters

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@gamli75

gamli75 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

/test verify-generated-code

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD d931df0 and 1 for PR HEAD dfabc69 in total

@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 15, 2026
This branch moves assisted-service from jackc/pgx/v4 (via older GORM
postgres driver and transitive pgtype/pgconn) to the stack required by
newer openshift-online/ocm-sdk-go, and aligns GORM, DSN construction,
custom DB types, OCM error handling, and subsystem WireMock with that
reality.

Dependency upgrades (go.mod / go.sum + vendor)
-----------------------------------------------
- github.com/openshift-online/ocm-sdk-go: v0.1.205 -> v0.1.499
  Brings in github.com/openshift-online/ocm-api-model/{clientapi,model}
  v0.0.453 and other transitive updates (e.g. skratchdot/open-golang).
  v0.1.499 is built for pgx v5; keeping ocm-sdk-go on v0.1.205 while
  moving the rest of the tree to pgx v5 is not viable.

- PostgreSQL driver stack:
  - gorm.io/driver/postgres: v1.3.5 -> v1.6.0 (uses pgx v5 under the hood)
  - gorm.io/gorm: v1.25.8 -> v1.25.10
  - Remove jackc/pgx/v4, pgconn, pgtype, pgio, chunkreader, pgproto3.
  - Add jackc/pgx/v5 v5.6.0 and jackc/puddle/v2 (pool support).
  - Bump jackc/pgservicefile to a release compatible with pgx v5.
  - Drop replace github.com/jackc/pgx/v4 => v4.18.3 (no longer used).

- golang.org/x/sys minor bump on the branch (toolchain alignment).

Submodule go.mod hygiene (api/, client/, models/)
------------------------------------------------
- Remove unused indirect jackc/pgio and jackc/pgtype from api/go.mod and
  client/go.mod.
- Remove github.com/jackc/pgtype and pgio from models/go.mod now that
  models/custom.go no longer references pgtype.

Why ocm-sdk-go v0.1.499 matters for assisted-service
----------------------------------------------------
assisted-service uses pkg/ocm against accountsmgmt/v1 for:

- ClusterAuthorizations().Post() — create AMS subscription at register.
- Subscriptions().Subscription(id).Get() — read subscription.
- Subscriptions().Subscription(id).Update().Body(sub).SendContext() —
  PATCH display name, console URL, external_cluster_id (OpenShift
  cluster ID), and status Active.
- Subscriptions().Subscription(id).Delete().SendContext() — delete
  subscription on cluster deregister.

Compared to v0.1.205, the newer SDK + ocm-api-model clientapi layer:

1) JSON encoding of API types (e.g. Subscription) is generated in
   ocm-api-model/clientapi (jsoniter, explicit field-set bitmaps).
   PATCH bodies always include a leading "kind" field and only the
   fields the builder set. That affects HTTP fixtures (subsystem
   WireMock) that matched only minimal JSON.

2) Subscription PATCH response handling: SendContext wraps the body in
   a bufio.Reader and uses Peek(1). If the server returns an HTTP error
   with an empty body, Peek hits io.EOF; the client returns with err == nil
   while result.status is still 4xx/5xx, and never unmarshals an
   errors.Error. assisted-service previously assumed "err != nil" for
   failures. pkg/ocm.HandleOCMResponse now treats response.Status() >= 400
   as failure even when err is nil (mirrors the intent of the generated
   error path when a body exists).

3) Error responses are unmarshalled into github.com/openshift-online/ocm-sdk-go/errors
   when the body is valid OCM "Error" JSON. Subsystem stubs that returned
   a subscription-shaped JSON body with HTTP 401 caused unmarshalling /
   downstream UTF-8 issues; stubs now return proper Error JSON for PATCH
   failures (see wiremock_stubs.go).

Per-file / functional changes
-------------------------------
pkg/db/db.go
- Add LibpqDSN(host, port, user, password, database) and Config.LibpqDSN().
- Build a libpq keyword connection string with escaped user/password for
  single quotes and backslashes.
- Append client_encoding=UTF8 so pgx v5 / GORM simple-query paths behave
  predictably regardless of server client_encoding defaults.

cmd/main.go
- setupDB: use Options.DBConfig.LibpqDSN() instead of hand-rolled
  host=... DSN (same semantics, safer quoting, UTF8).

internal/common/common_unitest_db.go
- getDBDSN: delegate to pkg/db.LibpqDSN for unit-test PostgreSQL so tests
  use the same DSN rules as production.

models/custom.go
- Remove dependency on github.com/jackc/pgtype (pgx v4 era).
- IP/Subnet driver.Valuer: encode inet/cidr using netip and return textual
  prefix strings PostgreSQL accepts.
- IP/Subnet sql.Scanner: accept netip.Prefix / *netip.Prefix as returned
  by pgx v5 for inet/cidr, in addition to legacy []byte, string, net.IP,
  *net.IPNet.

internal/bminventory/inventory.go
- InstallClusterInternal async goroutine: call storeOpenshiftClusterID
  with asyncCtx instead of the outer request ctx so S3/object-store work
  is not tied to an HTTP request deadline that can fire before AMS
  integration completes.

internal/cluster/cluster.go
- HandlePreInstallError: sanitize installErr.Error() with
  strings.ToValidUTF8 before persisting LastInstallationPreparation.Reason
  and emitting events. OCM error bodies / parse paths can produce strings
  that are not valid UTF-8; PostgreSQL text columns reject those writes.

pkg/ocm/utils.go
- HandleOCMResponse: after the existing err != nil handling, if response is
  non-nil and Status() >= 400, return InfraError (401 mapping) for 4xx
  and ApiError (503) for 5xx. Covers empty-body HTTP errors from newer
  SendContext implementations.

subsystem/utils_test/wiremock_stubs.go
- subscriptionPatchWiremockResponse: for resStatus >= 400, return OCM
  Error JSON so the SDK can UnmarshalErrorStatus; avoids subscription-
  shaped 401 bodies and invalid UTF-8 in DB reasons.
- Subscription PATCH external_cluster_id: use matchesJsonPath on
  $.external_cluster_id instead of equalToJson on a minimal template, so
  stubs stay stable across SDK JSON field order/extra fields and reduce
  ambiguous matching when many mappings exist.
- Add WireMock stubs for soft-timeouts org capability review and an
  accounts_mgmt stub for the cluster-editor test user so authorization
  flows match current API expectations.
@shay23bra shay23bra force-pushed the pgx-v5-migration-release-ocm-2.15 branch from dfabc69 to 419ba78 Compare July 15, 2026 10:12
@openshift-ci openshift-ci Bot removed lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jul 15, 2026
@openshift-ci

openshift-ci Bot commented Jul 15, 2026

Copy link
Copy Markdown

@shay23bra: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-ai-operator-disconnected-capi 5ab1398 link true /test e2e-ai-operator-disconnected-capi

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@gamli75

gamli75 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-review Categorizes an issue or PR as actively needing an API review. approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants