Skip to content

Go module upgrades to fix CVE-2025-22872#675

Merged
wallrj merged 6 commits into
masterfrom
go-mod-upgrade
Jun 25, 2025
Merged

Go module upgrades to fix CVE-2025-22872#675
wallrj merged 6 commits into
masterfrom
go-mod-upgrade

Conversation

@wallrj

@wallrj wallrj commented Jun 24, 2025

Copy link
Copy Markdown
Contributor

Fixes: CVE-2025-22872

Mostly mechanical changes to upgrade the Go module version and the x/net module to fix a CVE reported by trivy:

_bin/tools/go get golang.org/x/net@latest
_bin/tools/go get go@1.24.4
make go-tidy

Then I had to go and update the tests to use the new t.Context helper and fix some go vet warnings which started showing up.

Testing

Current Release:

$ trivy image registry.venafi.cloud/venafi-agent/venafi-agent:v1.5.0
2025-06-24T16:15:21+01:00       INFO    [vuln] Vulnerability scanning is enabled
2025-06-24T16:15:21+01:00       INFO    [secret] Secret scanning is enabled
2025-06-24T16:15:21+01:00       INFO    [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2025-06-24T16:15:21+01:00       INFO    [secret] Please see also https://trivy.dev/v0.61/docs/scanner/secret#recommendation for faster secret detection
2025-06-24T16:15:24+01:00       INFO    Detected OS     family="alpine" version="3.21"
2025-06-24T16:15:24+01:00       INFO    [alpine] Detecting vulnerabilities...   os_version="3.21" repository="3.21" pkg_num=2
2025-06-24T16:15:24+01:00       INFO    Number of language-specific files       num=1
2025-06-24T16:15:24+01:00       INFO    [gobinary] Detecting vulnerabilities...
2025-06-24T16:15:24+01:00       WARN    Using severities from other vendors for some vulnerabilities. Read https://trivy.dev/v0.61/docs/scanner/vulnerability#severity-selection for details.

Report Summary

┌──────────────────────────────────────────────────────────────────────┬──────────┬─────────────────┬─────────┐
│                                Target                                │   Type   │ Vulnerabilities │ Secrets │
├──────────────────────────────────────────────────────────────────────┼──────────┼─────────────────┼─────────┤
│ registry.venafi.cloud/venafi-agent/venafi-agent:v1.5.0 (alpine 3.21) │  alpine  │        0        │    -    │
├──────────────────────────────────────────────────────────────────────┼──────────┼─────────────────┼─────────┤
│ ko-app/preflight                                                     │ gobinary │        4        │    -    │
└──────────────────────────────────────────────────────────────────────┴──────────┴─────────────────┴─────────┘
Legend:
- '-': Not scanned
- '0': Clean (no security findings detected)


ko-app/preflight (gobinary)

Total: 4 (UNKNOWN: 0, LOW: 0, MEDIUM: 3, HIGH: 1, CRITICAL: 0)

┌──────────────────┬────────────────┬──────────┬────────┬───────────────────┬─────────────────┬──────────────────────────────────────────────────────────────┐
│     Library      │ Vulnerability  │ Severity │ Status │ Installed Version │  Fixed Version  │                            Title                             │
├──────────────────┼────────────────┼──────────┼────────┼───────────────────┼─────────────────┼──────────────────────────────────────────────────────────────┤
│ golang.org/x/net │ CVE-2025-22872 │ MEDIUM   │ fixed  │ v0.36.0           │ 0.38.0          │ golang.org/x/net/html: Incorrect Neutralization of Input     │
│                  │                │          │        │                   │                 │ During Web Page Generation in x/net in...                    │
│                  │                │          │        │                   │                 │ https://avd.aquasec.com/nvd/cve-2025-22872                   │
├──────────────────┼────────────────┼──────────┤        ├───────────────────┼─────────────────┼──────────────────────────────────────────────────────────────┤
│ stdlib           │ CVE-2025-22874 │ HIGH     │        │ v1.24.2           │ 1.24.4          │ crypto/x509: Usage of ExtKeyUsageAny disables policy         │
│                  │                │          │        │                   │                 │ validation in crypto/x509                                    │
│                  │                │          │        │                   │                 │ https://avd.aquasec.com/nvd/cve-2025-22874                   │
│                  ├────────────────┼──────────┤        │                   ├─────────────────┼──────────────────────────────────────────────────────────────┤
│                  │ CVE-2025-0913  │ MEDIUM   │        │                   │ 1.23.10, 1.24.4 │ Inconsistent handling of O_CREATE|O_EXCL on Unix and Windows │
│                  │                │          │        │                   │                 │ in os in syscall...                                          │
│                  │                │          │        │                   │                 │ https://avd.aquasec.com/nvd/cve-2025-0913                    │
│                  ├────────────────┤          │        │                   │                 ├──────────────────────────────────────────────────────────────┤
│                  │ CVE-2025-4673  │          │        │                   │                 │ net/http: Sensitive headers not cleared on cross-origin      │
│                  │                │          │        │                   │                 │ redirect in net/http                                         │
│                  │                │          │        │                   │                 │ https://avd.aquasec.com/nvd/cve-2025-4673                    │
└──────────────────┴────────────────┴──────────┴────────┴───────────────────┴─────────────────┴──────────────────────────────────────────────────────────────┘

Before:

$ trivy fs .
2025-06-24T15:47:24+01:00       INFO    [vuln] Vulnerability scanning is enabled
2025-06-24T15:47:24+01:00       INFO    [secret] Secret scanning is enabled
2025-06-24T15:47:24+01:00       INFO    [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2025-06-24T15:47:24+01:00       INFO    [secret] Please see also https://trivy.dev/v0.61/docs/scanner/secret#recommendation for faster secret detection
2025-06-24T15:47:25+01:00       INFO    Number of language-specific files       num=1
2025-06-24T15:47:25+01:00       INFO    [gomod] Detecting vulnerabilities...

Report Summary

┌────────┬───────┬─────────────────┬─────────┐
│ Target │ Type  │ Vulnerabilities │ Secrets │
├────────┼───────┼─────────────────┼─────────┤
│ go.mod │ gomod │        1        │    -    │
└────────┴───────┴─────────────────┴─────────┘
Legend:
- '-': Not scanned
- '0': Clean (no security findings detected)


go.mod (gomod)

Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 1, HIGH: 0, CRITICAL: 0)

┌──────────────────┬────────────────┬──────────┬────────┬───────────────────┬───────────────┬──────────────────────────────────────────────────────────┐
│     Library      │ Vulnerability  │ Severity │ Status │ Installed Version │ Fixed Version │                          Title                           │
├──────────────────┼────────────────┼──────────┼────────┼───────────────────┼───────────────┼──────────────────────────────────────────────────────────┤
│ golang.org/x/net │ CVE-2025-22872 │ MEDIUM   │ fixed  │ v0.36.0           │ 0.38.0        │ golang.org/x/net/html: Incorrect Neutralization of Input │
│                  │                │          │        │                   │               │ During Web Page Generation in x/net in...                │
│                  │                │          │        │                   │               │ https://avd.aquasec.com/nvd/cve-2025-22872               │
└──────────────────┴────────────────┴──────────┴────────┴───────────────────┴───────────────┴──────────────────────────────────────────────────────────┘

After:

$ trivy fs .
2025-06-24T16:12:16+01:00       INFO    [vuln] Vulnerability scanning is enabled
2025-06-24T16:12:16+01:00       INFO    [secret] Secret scanning is enabled
2025-06-24T16:12:16+01:00       INFO    [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2025-06-24T16:12:16+01:00       INFO    [secret] Please see also https://trivy.dev/v0.61/docs/scanner/secret#recommendation for faster secret detection
2025-06-24T16:12:17+01:00       INFO    Number of language-specific files       num=1
2025-06-24T16:12:17+01:00       INFO    [gomod] Detecting vulnerabilities...

Report Summary

┌────────┬───────┬─────────────────┬─────────┐
│ Target │ Type  │ Vulnerabilities │ Secrets │
├────────┼───────┼─────────────────┼─────────┤
│ go.mod │ gomod │        0        │    -    │
└────────┴───────┴─────────────────┴─────────┘
Legend:
- '-': Not scanned
- '0': Clean (no security findings detected)

Signed-off-by: Richard Wall <richard.wall@cyberark.com>
Signed-off-by: Richard Wall <richard.wall@cyberark.com>
Signed-off-by: Richard Wall <richard.wall@cyberark.com>
Signed-off-by: Richard Wall <richard.wall@cyberark.com>
Signed-off-by: Richard Wall <richard.wall@cyberark.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR upgrades the Go module versions—including the x/net module—to address CVE-2025-22872 while updating the tests to use the new t.Context() helper and fixing go vet warnings.

  • Upgraded module versions and Go version in go.mod
  • Replaced context.Background()/context.TODO() with t.Context() in multiple tests
  • Adjusted logging calls (including formatting strings) in test code

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/logs/logs_test.go Updated context usage and modified logging calls
pkg/internal/cyberark/servicediscovery/discovery_test.go Replaced context.Background() with t.Context()
pkg/internal/cyberark/identity/start_authentication_test.go Replaced context.Background() with t.Context()
pkg/internal/cyberark/identity/advance_authentication_test.go Replaced context.Background() with t.Context()
pkg/internal/cyberark/dataupload/dataupload_test.go Replaced context.TODO() with t.Context()
pkg/echo/echo_test.go Replaced context.TODO() with t.Context()
pkg/datagatherer/k8s/dynamic_test.go Replaced context.Background() with t.Context() in several test cases
pkg/client/client_venconn_test.go Updated context creation using t.Context() with cancellation
pkg/agent/config_test.go Updated context usage and YAML tests
go.mod Upgraded Go version and various dependency versions
cmd/agent_test.go Replaced context.Background() with t.Context() in the command test
Comments suppressed due to low confidence (1)

pkg/logs/logs_test.go:412

  • Ensure that the replacement of logger.Printf with logger.Print retains the intended formatting behavior, especially if any format specifiers were expected. If formatting is required, consider using logger.Printf with an appropriate format string.
		logger.Print(line)

Comment thread pkg/logs/logs_test.go Outdated
for _, line := range strings.Split(given, "\n") {
// Simulate the current agent's logs.
logger.Printf(line) // nolint:staticcheck
logger.Print(line)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maelvls I wasn't sure about this. This nolint annotation no longer works, and I couldn't find a working nolint trick. So I changed printf to print. Does that invalidate these tests?

@maelvls maelvls Jun 24, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I misunderstand the point of this test, I think you can remove this test entirely since there aren't any log.Fatal or log.Print calls anymore:

$ rg 'log\.(Print|Fatal)'             
pkg/logs/logs.go
126:    // the agent, which still uses log.Printf.
151:    // log.Printf writes a newline at the end of the message, so we need to trim

pkg/logs/logs_test.go
59:             log.Print("log Print")

Back when we added this test case in 415d434, there were many more lines:

pkg/agent/config.go:			log.Printf("Using the %s auth mode since --venafi-cloud and --credentials-path were specified.", mode)
pkg/agent/config.go:			log.Printf("Using the %s auth mode since --client-id and --private-key-path were specified.", mode)
pkg/agent/config.go:			log.Printf("Using the %s auth mode since --venafi-connection was specified.", mode)
pkg/agent/config.go:			log.Printf("Using the %s auth mode since --api-token was specified.", mode)
pkg/agent/config.go:			log.Printf("Using the %s auth mode since --credentials-file was specified without --venafi-cloud.", mode)
pkg/agent/config.go:			log.Printf("The `server` and `endpoint` fields are both set in the config; using the `server` field.")
pkg/agent/config.go:			log.Printf("Using deprecated Endpoint configuration. User Server instead.")
pkg/agent/config.go:			log.Printf("ignoring the server field specified in the config file. In %s mode, this field is not needed.", VenafiCloudVenafiConnection)
pkg/agent/config.go:				log.Printf(`ignoring the venafi-cloud.upload_path field in the config file. In %s mode, this field is not needed.`, res.AuthMode)
pkg/agent/config.go:			log.Printf(`ignoring the venafi-cloud.uploader_id field in the config file. This field is not needed in %s mode.`, res.AuthMode)
pkg/agent/config.go:			log.Printf("Using period from config %s", cfg.Period)
pkg/agent/config.go:			log.Printf("Both the 'period' field and --period are set. Using the value provided with --period.")
pkg/agent/config.go:			log.Println("Loading upload_path from \"venafi-cloud\" configuration.")
pkg/logs/logs.go:	// the agent, which still uses log.Printf.
pkg/logs/logs.go:	// log.Printf writes a newline at the end of the message, so we need to trim
pkg/logs/logs_test.go:		log.Print("log Print")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes. I vaguely remember. Thanks. Test now deleted.

@wallrj
wallrj requested a review from maelvls June 24, 2025 15:28
We have since replaced all the calls to log.Print and log.Fatal

Signed-off-by: Richard Wall <richard.wall@cyberark.com>
@wallrj
wallrj merged commit 52277e1 into master Jun 25, 2025
2 checks passed
@wallrj
wallrj deleted the go-mod-upgrade branch June 25, 2025 08:23
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.

4 participants