Skip to content

Centralize and harden vault secret identifier validation#22119

Open
russell-stern wants to merge 4 commits intodevelopfrom
priv-434-blob-broadcaster-property-test
Open

Centralize and harden vault secret identifier validation#22119
russell-stern wants to merge 4 commits intodevelopfrom
priv-434-blob-broadcaster-property-test

Conversation

@russell-stern
Copy link
Copy Markdown
Contributor

@russell-stern russell-stern commented Apr 21, 2026

  • Added secret identifier validation to all calls through the gateway
  • Centralized validator logic and removed duplicated logic from plugin
  • Added a smoke test to make sure the gateway and workflows are validating the secret identifier
  • Added a test helper to create ReportPlugin and updated all tests to use the new helper
  • Added tests to make sure owner specific overrides are applied in validation

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 21, 2026

✅ No conflicts with other open PRs targeting develop

@trunk-io
Copy link
Copy Markdown

trunk-io Bot commented Apr 21, 2026

Static BadgeStatic BadgeStatic BadgeStatic Badge

Failed Test Failure Summary Logs
Test_CRE_V2_Aptos_Suite The test failed without a specific error message, indicating an unspecified failure during execution. Logs ↗︎
Test_CRE_V2_Aptos_Suite/[v2]_Aptos/Aptos_Write_Read_Roundtrip The test failed because it could not find the expected user log message during the Aptos write/read roundtrip test. Logs ↗︎
Test_CRE_V2_Aptos_Suite/[v2]_Aptos Logs ↗︎
Test_CRE_V2_Aptos_Suite/[v2]_Aptos/Aptos_Write_Read_Roundtrip Logs ↗︎

... and 2 more

View Full Report ↗︎Docs

Comment thread core/services/ocr2/plugins/vault/plugin_test.go Outdated
Comment thread core/services/ocr2/plugins/vault/plugin_test.go Outdated
},
}
fetcher := &callbackBlobFetcher{fn: func([]byte) error { return nil }}
result, err := r.broadcastBlobPayloads(t.Context(), fetcher, 1, payloads, ids)
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.

🤔 This will never fail I think -- your callbackBlobFetcher isn't the real fetcher that would be injected, so in other words even if you passed a payload that was too big, the test would still succeed

I would suggest instead checking against the plugin limit value instantiated by the NewReportingPlugin function

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.

I have that check below but you're right the runBroadcast isn't actually testing anything. I removed the call altogether and since the blob limit is per payload the batch size doesn't matter. I removed the loop that created multiple payloads and we're just checking against the max size payload for each request type

@russell-stern russell-stern force-pushed the priv-434-blob-broadcaster-property-test branch from b6f88a8 to 1bc64cc Compare April 22, 2026 17:03
Copy link
Copy Markdown
Contributor

@prashantkumar1982 prashantkumar1982 left a comment

Choose a reason for hiding this comment

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

Thanks for these new validation tests :)

But looking at these, I think we should do this validation in more layers in our stack. See detailed comments.

name string
id *vaultcommon.SecretIdentifier
maxIDLen int
maxOwnerLen int
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.

These 3 limits on max values should ideally be tested inside the validator too.
OCR plugin is too deep in our stack to be the only place to validate these.
I mean look at this code:

if req.Id.Key == "" || req.Id.Namespace == "" || req.Id.Owner == "" {
return errors.New("secret ID must have key, namespace and owner set at index " + strconv.Itoa(idx) + ":" + req.Id.String())
}

This code too should be checking these limits and failing.

@cedric-cordenier what do you think?

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.

Yes agreed 👍

@github-actions
Copy link
Copy Markdown
Contributor

I see you updated files related to core. Please run make gocs in the root directory to add a changeset as well as in the text include at least one of the following tags:

  • #added For any new functionality added.
  • #breaking_change For any functionality that requires manual action for the node to boot.
  • #bugfix For bug fixes.
  • #changed For any change to the existing functionality.
  • #db_update For any feature that introduces updates to database schema.
  • #deprecation_notice For any upcoming deprecation functionality.
  • #internal For changesets that need to be excluded from the final changelog.
  • #nops For any feature that is NOP facing and needs to be in the official Release Notes for the release.
  • #removed For any functionality/config that is removed.
  • #updated For any functionality that is updated.
  • #wip For any change that is not ready yet and external communication about it should be held off till it is feature complete.

@russell-stern russell-stern force-pushed the priv-434-blob-broadcaster-property-test branch 3 times, most recently from e2ff881 to 98b873e Compare April 28, 2026 14:33
@russell-stern russell-stern changed the title Added tests for vault blob broadcast size and batch request limit in … Centralize and harden vault secret identifier validation Apr 28, 2026
@russell-stern russell-stern marked this pull request as ready for review April 28, 2026 18:50
@russell-stern russell-stern requested review from a team as code owners April 28, 2026 18:50

// ownerOverrideLimiter is a BoundLimiter that applies different size limits based on the owner in context.
// This lets tests verify that the validator correctly threads the owner through context to the limiter.
type ownerOverrideLimiter struct {
Copy link
Copy Markdown
Contributor

@jmank88 jmank88 Apr 28, 2026

Choose a reason for hiding this comment

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

I'm not sure that faking this is a good idea. What do the tests actually evaluate if we skip past coverage of a real limiter? Typically we just pass a settings.Getter to the limits factory.

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.

This is testing to make sure that we're passing in the owner into the context during the validation calls. There were places where we weren't and weren't applying higher limits for owners that had it set. This is only used in tests that are testing if we're applying the right limits per owner

return capabilities.CapabilityResponse{}, errors.New("unsupported method: can only call GetSecrets via capability interface")
}

r := &vaultcommon.GetSecretsRequest{}
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.

I know we've been missing this code always.
But we should call validation on this request object too.
Reason is because this field is also coming from a workflow user, and can have invalid details.

@cedric-cordenier : We were always missing validation for GetSecrets() path whcih comes via workflows. The content is not validated anywhere before plugin.

@russell-stern russell-stern force-pushed the priv-434-blob-broadcaster-property-test branch from 0f7644e to 9e578d6 Compare April 30, 2026 20:15
@cl-sonarqube-production
Copy link
Copy Markdown

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