Skip to content

feat: add Sigma Config provider (M2/M3 review) - #1

Open
kongo1999 wants to merge 12 commits into
mainfrom
feat/sigmaconfig-provider
Open

kongo1999 wants to merge 12 commits into
mainfrom
feat/sigmaconfig-provider

Conversation

@kongo1999

Copy link
Copy Markdown
Collaborator

Review PR for the Sigma Config provider: the M2 code review, plus M3 bulk reads and the M4 docs.

What's in it

  • Read-only sigmaconfig provider: single reads (property, version/tag), dataFrom.extract, dataFrom.find.name.regexp
  • Shared 30 s project cache, bulk fetch (page_size=1000), 429/Retry-After handling, one retry on 5xx/timeouts
  • TLS always verified, with optional caBundle/caProvider; the client offers only HTTP/1.1
  • Unit tests (92.6% coverage) and the e2e suite (keys from env vars only)
  • Docs page, snippets, stability/support rows (maintainers: Ayodehi, AbsolutOD), CODEOWNERS entry

Results on Brindlecove staging

  • e2e: 2 of 3 full runs done, 18/18 passing each time
  • Parity with the CLI: 42/42 match
  • Log hygiene: no keys or seed values in the logs (run 1)

Not for merge into main here. After review, this goes upstream as a PR to external-secrets/external-secrets.

AI assistance: Claude Code helped write code, tests and docs. I reviewed and tested every change.

🤖 Generated with Claude Code

Add the SigmaConfig store types (server, project, environment, tag, apiKeySecretRef, caBundle, caProvider), register the provider under the sigmaconfig/all_providers build tags, and implement ValidateStore and read-only Capabilities. NewClient returns a not-implemented error until the client lands.

Signed-off-by: Elie Kanaan <eliekanaan757@gmail.com>
Add a read-only Sigma Config API client (GET only, one retry on 502/503/504 and timeouts, never on 4xx, same-host pagination), a process-wide 30s snapshot cache with single-flight fills, and GetSecret with property, version (tag) and template-error by-name fallback. Map API errors to messages that never include the API key or values. NewClient reads the key from the referenced Secret and adds caBundle/caProvider to the system roots. GetSecretMap and GetAllSecrets follow in M3.

Signed-off-by: Elie Kanaan <eliekanaan757@gmail.com>
GetSecretMap expands a JSON object parameter into one key per field. GetAllSecrets returns parameters matching find.name.regexp under their original names, skips unset ones, rejects find.tags and find.path, and fails the whole read on a template error so a partial result never drops keys from the target Secret. All read paths share one cached snapshot. Add an e2e suite for Sigma Config cases P-01 to P-18 that reads expected values from the API at run time, never prints values, and skips without SIGMA_CONFIG_API_KEY and SIGMA_CONFIG_NOGRANT_API_KEY; it is listed but disabled in the e2e matrix. Pin tidwall/pretty to the workspace version.

Signed-off-by: Elie Kanaan <eliekanaan757@gmail.com>
The previous commit dropped the file mode from 100755 to 100644 when the SIGMA_CONFIG_* env lines were added.

Signed-off-by: Elie Kanaan <eliekanaan757@gmail.com>
The cloned default transport keeps h2 in NextProtos while HTTP/2 is disabled on it, so HTTP/2 servers such as the Sigma Config API answered with frames the client could not read. Set NextProtos to http/1.1 on every client, and make the test server offer HTTP/2.

Signed-off-by: Elie Kanaan <eliekanaan757@gmail.com>
Signed-off-by: Elie Kanaan <eliekanaan757@gmail.com>
Signed-off-by: Elie Kanaan <eliekanaan757@gmail.com>
Signed-off-by: Elie Kanaan <eliekanaan757@gmail.com>

# Conflicts:
#	go.mod
Signed-off-by: Elie Kanaan <eliekanaan757@gmail.com>
Signed-off-by: Elie Kanaan <eliekanaan757@gmail.com>
@AbsolutOD

Copy link
Copy Markdown
Collaborator

Security review: Sigma Config provider

This review looks at security before the PR goes upstream to External Secrets. It was AI-assisted and based only on reading the diff at 9da3dc4. None of these findings have been reproduced or tested, and make test / make check-diff were not run. Please check each one and reply with confirmed or not an issue (and why) before it goes upstream.

Must fix before upstream

1. A failed external pull is reported as "secret missing" (client.go:70)
GetSecret checks pv.value == nil and returns esv1.NoSecretErr before it checks externalError. When an external reference (AWS/Azure) fails, the API returns value=null with external_status.error_code set, so the error branch is never reached. With deletionPolicy: Delete, a temporary upstream failure deletes the user's Kubernetes Secret.
Suggested fix: check externalError before value == nil.

2. The API key can leak through redirects (provider.go:163)
The http.Client has no CheckRedirect. On a same-host redirect, Go keeps the Authorization: Api-Key header even when the redirect drops from https to http. A misconfigured load balancer or a TLS-inspecting proxy (the documented caBundle use case) answering 301 to http://api.cloudtruth.io/... would send the key in cleartext. This also gets around checkSameHost and the https-only checks.
Suggested fix: reject all redirects, or at least non-https and cross-host ones.

Should fix

3. A failed external pull silently drops the key (client.go:264)
GetAllSecrets has the same ordering as item 1: it continues on a nil value, so a dataFrom.find sync succeeds without the key and overwrites the Secret. That contradicts the docs, which say a failed find keeps the previous data.

4. Pagination has no limit (api/client.go:149)
If next loops (for example, it returns the same URL every time), the loop keeps going until the reconcile context ends. Each request has its own 30 s timeout, but the loop has none. This spends the org's shared 5,000 req/h budget and can add up to 64 MiB per page to memory.
Suggested fix: cap the number of pages and/or detect a repeated next.

5. Server error text is passed verbatim into errors (errors.go:59)
The code already drops template error messages because they can quote rendered values. ae.Detail in the 400 branch and the default %w branch can quote a secret the same way (for example, a validation message), and it ends up in controller logs and ExternalSecret status. It also allows log injection through Detail and RetryAfter.

6. A panic in the cache fill can deadlock all Sigma Config reconciles (cache.go:99)
If fill() panics, p.snap stays nil, and the deferred function reads p.snap.err while holding c.mu. That causes a second panic with the mutex still locked and pending[key] never closed. controller-runtime recovers the panic, but every later cache.get hangs until the pod restarts.

7. Callers waiting on a shared fetch ignore their own context (cache.go:89)
Waiters block on <-p.done without a select on ctx.Done(), and the fetch runs with the first caller's context. On a slow project with many pages, controller workers stay tied up. Together with item 4, this makes a DoS worse.

8. remoteRef.version lets a tenant drain the shared API budget (client.go:62)
Any tag string is accepted, and each distinct one triggers its own full-project fetch with mask_secrets=false. A tenant who can only create a namespaced ExternalSecret against a shared store can use up the org-wide rate limit. Many distinct tags also push other users' entries out of the 256-entry cache.

9. Memory use is effectively unbounded (api/client.go:45)
Each page can be 64 MiB, and the process-wide cache holds up to 256 decoded whole-project snapshots with secrets in plaintext. That risks the controller being killed for running out of memory, and every secret in a project stays in memory even when only one key is needed.

10. ValidateStore doesn't check caProvider (provider.go:176)
The webhook accepts wrong namespace scoping (namespace required on ClusterSecretStore, not allowed on SecretStore) and caBundle + caProvider set together. The problem only shows up later as a runtime error from FetchCACertFromSource. Other providers reject this at admission.

Upstream housekeeping

  • The e2e suite's default server is the vendor staging host api.staging.cloudtruth.io.
  • CODEOWNERS names @external-secrets/provider-sigmaconfig-reviewers, which probably doesn't exist upstream yet.
  • The root go.mod requires the module as v0.0.0, while other providers use a pseudo-version.

What looks sound

  • TLS is always verified with a TLS 1.2 minimum, and a custom CA is added to the system roots rather than replacing them.
  • It uses esutils.CloneDefaultHTTPTransport() and resolvers.SecretKeyRef as the repo requires.
  • Push, Delete and SecretExists return a sentinel error, not nil.
  • Cache keys use a hash of the API key, never the key itself.
  • caProvider namespace rules are still enforced at runtime by FetchCACertFromSource.

kongo1999 and others added 2 commits November 19, 2026 17:56
Report failed external pulls before null values, refuse redirects, bound pagination, keep server text out of errors, make the cache safe on panic and honour waiter contexts, validate caProvider at admission, use a pseudo-version in go.mod.
…#7337)

Signed-off-by: baraka-akeyless <barak.a@akeyless.io>
Co-authored-by: Cursor <cursoragent@cursor.com>
(cherry picked from commit 498c032)
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.

3 participants