security: validate Firebase credential file before auth #13
<!-- review-superseded: {"report_comment_id": 7019921907, "run_id": "44598575980", "run_attempt": "1"} -->
<details>
<summary>Superseded — see the <a href="https://github.com/ConductorOne/baton-google-identity-platform/pull/13#issuecomment-7019921907">current review report</a> for commit <code>6ce287dd9a4c</code></summary>
Connector PR Review: security: validate Firebase credential file before auth
Blocking Issues: 0 | Suggestions: 1 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base fba77b1f295f.
_Review mode: full_
View review run
Review Summary
New() no longer uses option.WithCredentialsFile. It now opens the configured path itself and reads at most MaxJSONBytes+1 bytes. The vendored google-credential-guard v0.1.1 (guard.go) parses those bytes with a field allowlist and duplicate-key and trailing-data rejection. It accepts only type=service_account with an RSA PKCS#8 key, a *.gserviceaccount.com email, and a pinned token_uri/universe_domain. It re-encodes the key as canonical JSON and passes it through the typed option.WithAuthCredentialsJSON(option.ServiceAccount, …).Firebase now gets &firebase.Config{} instead of nil. That skips getConfigDefaults, so FIREBASE_CONFIG is no longer read. The project ID still comes from the service-account credentials via getProjectID → transport.Creds, which supports AuthCredentialsJSON in the bumped google.golang.org/api v0.316.0.
I scanned the full PR diff for security and correctness. The go.mod/go.sum changes match the new guard dependency and the refreshed Google auth/API modules it needs; go.sum only adds entries. vendor/modules.txt is consistent with go.mod. I did not review third-party vendored module contents line by line, apart from the guard package.
Repo-local criteria applied: no resource-producing paths changed, so sections S/R7 don't apply. No Grants, actions, or spans changed. Error wrapping (B) is fine: %w is kept on the guard error, and the guard's messages carry no path or key data. The user.go change only adds //nolint:staticcheck notes and leaves trait output the same, so B6 doesn't apply.
Rejecting authorized_user/external_account files and the ADC fallback is a deliberate narrowing. The README documents it, and docs/connector.mdx already says to use a JSON service-account key. credentials-json-file-path is WithRequired(true), so an empty path cannot rely on the old ADC fallback. The tests cover a valid key, external-account variants, a hostile token_uri, oversized input, and leakage of the path into errors.
Security Issues
None found.
Correctness Issues
None found.
Suggestions
pkg/connector/connector.go:85, :72: the sanitized errors drop their cause entirely. "open credentials file: failed" doesn't separate not-found, permission-denied, or is-a-directory, and the Firebase auth client error is fully discarded. That makes CLI misconfiguration hard to diagnose. You could classify the cause without the path, e.g. with fs.ErrNotExist / fs.ErrPermission.<details>
<summary>Prompt for AI agents</summary>
Verify each finding against the current code and only fix it if needed.
## Suggestions
In `pkg/connector/connector.go`:
- Around line 83-86: `credentialsOption` replaces every os.Open error with "open credentials file: failed". Keep the path out of the message, but classify the cause: if errors.Is(err, fs.ErrNotExist) return "open credentials file: not found"; if errors.Is(err, fs.ErrPermission) return "open credentials file: permission denied"; otherwise keep the generic message.
- Around line 70-73: the error from app.Auth(ctx) is discarded completely. If it can be done without exposing credential content, keep a non-sensitive classification of the cause so operators can diagnose initialization failures.
</details>
</details>
🟡 Suggestion (low confidence): this error drops the cause along with the path, so an operator can't tell a missing file from a permissions problem or a directory. You can keep the path out of the error and still name the class, e.g. errors.Is(err, fs.ErrNotExist) → "not found", fs.ErrPermission → "permission denied". The same applies to the bare "initialize Firebase auth client: failed" at line 72.
<!-- review-superseded: {"report_comment_id": 7020279065, "run_id": "44601216077", "run_attempt": "1"} -->
<details>
<summary>Superseded — see the <a href="https://github.com/ConductorOne/baton-google-identity-platform/pull/13#issuecomment-7020279065">current review report</a> for commit <code>bb7787af9bdc</code></summary>
Connector PR Review: security: validate Firebase credential file before auth
Blocking Issues: 0 | Suggestions: 1 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base fba77b1f295f.
_Review mode: full_
View review run
Review Summary
New() no longer uses option.WithCredentialsFile. It now opens the configured path itself and reads at most MaxJSONBytes+1 bytes. The vendored google-credential-guard v0.1.1 (guard.go) parses those bytes with a field allowlist and duplicate-key and trailing-data rejection. It accepts only type=service_account with an RSA PKCS#8 key, a *.gserviceaccount.com email, and a pinned token_uri/universe_domain. It re-encodes the key as canonical JSON and passes it through the typed option.WithAuthCredentialsJSON(option.ServiceAccount, …).Firebase now gets &firebase.Config{} instead of nil. That skips getConfigDefaults, so FIREBASE_CONFIG is no longer read. The project ID still comes from the service-account credentials via getProjectID → transport.Creds, which supports AuthCredentialsJSON in the bumped google.golang.org/api v0.316.0.
I scanned the full PR diff for security and correctness. The go.mod/go.sum changes match the new guard dependency and the refreshed Google auth/API modules it needs; go.sum only adds entries. vendor/modules.txt is consistent with go.mod. I did not review third-party vendored module contents line by line, apart from the guard package.
Repo-local criteria applied: no resource-producing paths changed, so sections S/R7 don't apply. No Grants, actions, or spans changed. Error wrapping (B) is fine: %w is kept on the guard error, and the guard's messages carry no path or key data. The user.go change only adds //nolint:staticcheck notes and leaves trait output the same, so B6 doesn't apply.
Rejecting authorized_user/external_account files and the ADC fallback is a deliberate narrowing. The README documents it, and docs/connector.mdx already says to use a JSON service-account key. credentials-json-file-path is WithRequired(true), so an empty path cannot rely on the old ADC fallback. The tests cover a valid key, external-account variants, a hostile token_uri, oversized input, and leakage of the path into errors.
Security Issues
None found.
Correctness Issues
None found.
Suggestions
pkg/connector/connector.go:85, :72: the sanitized errors drop their cause entirely. "open credentials file: failed" doesn't separate not-found, permission-denied, or is-a-directory, and the Firebase auth client error is fully discarded. That makes CLI misconfiguration hard to diagnose. You could classify the cause without the path, e.g. with fs.ErrNotExist / fs.ErrPermission.<details>
<summary>Prompt for AI agents</summary>
Verify each finding against the current code and only fix it if needed.
## Suggestions
In `pkg/connector/connector.go`:
- Around line 83-86: `credentialsOption` replaces every os.Open error with "open credentials file: failed". Keep the path out of the message, but classify the cause: if errors.Is(err, fs.ErrNotExist) return "open credentials file: not found"; if errors.Is(err, fs.ErrPermission) return "open credentials file: permission denied"; otherwise keep the generic message.
- Around line 70-73: the error from app.Auth(ctx) is discarded completely. If it can be done without exposing credential content, keep a non-sensitive classification of the cause so operators can diagnose initialization failures.
</details>
---
Reviewed commit: 6ce287dd9a4c
<!-- review-state: {"last_reviewed_sha": "6ce287dd9a4c9e3e52fa538444980f7b492c70e5", "base_sha": "fba77b1f295fbdefa5d86ff99bfbd94d37839886", "workflow_ref": "ConductorOne/github-workflows/.github/workflows/pr-review.yaml@refs/heads/main", "run_id": "44598575980", "run_attempt": "1", "summary_marker": "### Connector PR Review:", "verdict_mode": "baseline", "publication": "completed", "started_at": "2026-11-19T19:28:05Z", "working_comment_id": 7019874130, "working_comment_updated_at": "2026-11-19T19:29:42Z"} -->
</details>
No blocking issues found — see the full review report
<!-- review-publication: {"run_id": "44598575980", "run_attempt": "1", "workflow_ref": "ConductorOne/github-workflows/.github/workflows/pr-review.yaml@refs/heads/main", "summary_marker": "### Connector PR Review:", "verdict_mode": "baseline", "report_comment_id": 7019921907} -->
<!-- review-superseded: {"report_comment_id": 7020279065, "run_id": "44601216077", "run_attempt": "1"} -->
<details>
<summary>Superseded — see the <a href="https://github.com/ConductorOne/baton-google-identity-platform/pull/13#issuecomment-7020279065">current review report</a> for commit <code>bb7787af9bdc</code></summary>
Connector PR Review: security: validate Firebase credential file before auth
Blocking Issues: 0 | Suggestions: 1 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base fba77b1f295f.
_Review mode: incremental since 6ce287d_
View review run
Review Summary
Since
6ce287d, three things changed. credentialsOption now reports not-found and permission-denied separately, without putting the path in the error. It also Stats the opened file and rejects anything that is not a regular file before the bounded read. And google-credential-guard moved from v0.1.1 to v0.1.2, which also accepts Google's current Console key variants (accounts.google.com/o/oauth2/token token URI, PKCS#1 RSA PRIVATE KEY). Either way, the guard always writes out canonical service-account JSON pinned to oauth2.googleapis.com/token. New tests cover the missing-file and directory cases.I scanned the full PR diff for security and correctness. That includes the vendored guard (guard.go, adapters.go) and vendor/modules.txt, which the incremental artifact had dropped. vendor/modules.txt matches go.mod at v0.1.2. The go.sum changes are tidy pruning of superseded Google auth/API hashes plus a few transitive /go.mod hashes. I applied the repo-local criteria: logging/error classification, sync data loss (S), JSON safety, breaking changes and dependency checks. None of them fire. This is init-only credential loading with no sync, provisioning, endpoint or resource-ID changes.
Security Issues
None found.
Correctness Issues
None found.
Suggestions
pkg/connector/connector.go:66-74. New still throws away the underlying Firebase errors ("initialize Firebase app: invalid configuration", "initialize Firebase auth client: failed"), so these init failures are hard to diagnose. The part of the earlier finding about os.Open cause classification is fixed (see below).Resolved prior findings
os.Open errors collapsed into one generic message: fixed. pkg/connector/connector.go:86-91 now checks fs.ErrNotExist and fs.ErrPermission without putting the path in the error, and :94-100 adds a sanitized non-regular-file check. Tested in pkg/connector/credentials_test.go:102-108.<details>
<summary>Prompt for AI agents</summary>
Verify each finding against the current code and only fix it if needed.
## Suggestions
In `pkg/connector/connector.go`:
- Around line 66-74: New() replaces errors from firebase.NewApp and app.Auth with fixed strings, so the underlying cause is lost. If those errors are confirmed not to contain credential material, wrap them with %w. Otherwise, map them to a coarse category (or log the cause at Debug) so operators can diagnose init failures without exposing key data.
</details>
</details>
I added path-free classifications for missing files, permission denial, and non-regular files at bb7787af, with regressions for missing path and directory. Firebase auth-client initialization still returns a generic class because its returned error may carry credential or environment details; we can narrow that further when we have a known safe error taxonomy. Full local tests and lint pass.
<!-- review-superseded: {"report_comment_id": 7020999199, "run_id": "44606333099", "run_attempt": "1"} -->
<details>
<summary>Superseded — see the <a href="https://github.com/ConductorOne/baton-google-identity-platform/pull/13#issuecomment-7020999199">current review report</a> for commit <code>7915c52ef180</code></summary>
Connector PR Review: security: validate Firebase credential file before auth
Blocking Issues: 0 | Suggestions: 1 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base fba77b1f295f.
_Review mode: incremental since 6ce287d_
View review run
Review Summary
Since
6ce287d, three things changed. credentialsOption now reports not-found and permission-denied separately, without putting the path in the error. It also Stats the opened file and rejects anything that is not a regular file before the bounded read. And google-credential-guard moved from v0.1.1 to v0.1.2, which also accepts Google's current Console key variants (accounts.google.com/o/oauth2/token token URI, PKCS#1 RSA PRIVATE KEY). Either way, the guard always writes out canonical service-account JSON pinned to oauth2.googleapis.com/token. New tests cover the missing-file and directory cases.I scanned the full PR diff for security and correctness. That includes the vendored guard (guard.go, adapters.go) and vendor/modules.txt, which the incremental artifact had dropped. vendor/modules.txt matches go.mod at v0.1.2. The go.sum changes are tidy pruning of superseded Google auth/API hashes plus a few transitive /go.mod hashes. I applied the repo-local criteria: logging/error classification, sync data loss (S), JSON safety, breaking changes and dependency checks. None of them fire. This is init-only credential loading with no sync, provisioning, endpoint or resource-ID changes.
Security Issues
None found.
Correctness Issues
None found.
Suggestions
pkg/connector/connector.go:66-74. New still throws away the underlying Firebase errors ("initialize Firebase app: invalid configuration", "initialize Firebase auth client: failed"), so these init failures are hard to diagnose. The part of the earlier finding about os.Open cause classification is fixed (see below).Resolved prior findings
os.Open errors collapsed into one generic message: fixed. pkg/connector/connector.go:86-91 now checks fs.ErrNotExist and fs.ErrPermission without putting the path in the error, and :94-100 adds a sanitized non-regular-file check. Tested in pkg/connector/credentials_test.go:102-108.<details>
<summary>Prompt for AI agents</summary>
Verify each finding against the current code and only fix it if needed.
## Suggestions
In `pkg/connector/connector.go`:
- Around line 66-74: New() replaces errors from firebase.NewApp and app.Auth with fixed strings, so the underlying cause is lost. If those errors are confirmed not to contain credential material, wrap them with %w. Otherwise, map them to a coarse category (or log the cause at Debug) so operators can diagnose init failures without exposing key data.
</details>
---
Reviewed commit: bb7787af9bdc
<!-- review-state: {"last_reviewed_sha": "bb7787af9bdc549e3c4445c4685bd5ad5558c226", "base_sha": "fba77b1f295fbdefa5d86ff99bfbd94d37839886", "workflow_ref": "ConductorOne/github-workflows/.github/workflows/pr-review.yaml@refs/heads/main", "run_id": "44601216077", "run_attempt": "1", "summary_marker": "### Connector PR Review:", "verdict_mode": "baseline", "publication": "completed", "started_at": "2026-11-19T19:43:20Z", "working_comment_id": 7020246979, "working_comment_updated_at": "2026-11-19T19:44:35Z"} -->
</details>
No blocking issues found — see the full review report
<!-- review-publication: {"run_id": "44601216077", "run_attempt": "1", "workflow_ref": "ConductorOne/github-workflows/.github/workflows/pr-review.yaml@refs/heads/main", "summary_marker": "### Connector PR Review:", "verdict_mode": "baseline", "report_comment_id": 7020279065} -->
The file side now reports not-found, permission-denied, and non-regular-file classes without returning the path. For app.Auth, I kept the text generic deliberately: the vendored Firebase signer at vendor/firebase.google.com/go/auth/token_generator.go:115-124 can format the full private key into its raw error when parsing fails. Wrapping or logging that error would risk key disclosure if an SDK change or parser differential reaches it. I added this rationale in the code at 7915c52e; full Go tests and lint pass. A future safe provider-error taxonomy can add categories without forwarding raw Firebase text.
<!-- review-superseded: {"report_comment_id": 7020999199, "run_id": "44606333099", "run_attempt": "1"} -->
<details>
<summary>Superseded — see the <a href="https://github.com/ConductorOne/baton-google-identity-platform/pull/13#issuecomment-7020999199">current review report</a> for commit <code>7915c52ef180</code></summary>
Connector PR Review: security: validate Firebase credential file before auth
Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base fba77b1f295f.
_Review mode: incremental since bb7787a_
View review run
Review Summary
The new commit changes no code. It adds a comment at
pkg/connector/connector.go:73-74 saying the error from app.Auth is kept generic on purpose, because Firebase's signer error can print the full private key.I re-scanned all the non-vendor changes for security and correctness: README.md, go.mod/go.sum, connector.go, credentials_test.go and user.go. The old WithCredentialsFile loader is replaced by credentialsOption. It opens the file with error messages that never include the path, accepts only regular files, reads at most 64 KiB, validates the key with google-credential-guard, and passes an explicit firebase.Config{} so FIREBASE_CONFIG is never read. The new direct dependency (google-credential-guard v0.1.2) and the Google auth/API version bumps that come with it match this change.
The vendored diffs were not reviewed line by line. I only checked that they line up with the go.mod bumps.
How the repo-local criteria applied:
List/Grants are unchanged, so it does not apply.One mismatch in the PR description: the summary says guard v0.1.1, but go.mod pins v0.1.2, which is also the version the compatibility section describes.
Security Issues
None found.
Correctness Issues
None found.
Suggestions
None.
Resolved prior findings
New throws away the underlying Firebase init errors (connector.go:66-75) is obsolete as a defect. The new comment at connector.go:73-74 records why: Firebase's signer error can include the private key. Keeping the message generic is the right security choice, so this is no longer a finding.</details>
Connector PR Review: security: validate Firebase credential file before auth
Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base fba77b1f295f.
_Review mode: incremental since bb7787a_
View review run
Review Summary
The new commit changes no code. It adds a comment at
pkg/connector/connector.go:73-74 saying the error from app.Auth is kept generic on purpose, because Firebase's signer error can print the full private key.I re-scanned all the non-vendor changes for security and correctness: README.md, go.mod/go.sum, connector.go, credentials_test.go and user.go. The old WithCredentialsFile loader is replaced by credentialsOption. It opens the file with error messages that never include the path, accepts only regular files, reads at most 64 KiB, validates the key with google-credential-guard, and passes an explicit firebase.Config{} so FIREBASE_CONFIG is never read. The new direct dependency (google-credential-guard v0.1.2) and the Google auth/API version bumps that come with it match this change.
The vendored diffs were not reviewed line by line. I only checked that they line up with the go.mod bumps.
How the repo-local criteria applied:
List/Grants are unchanged, so it does not apply.One mismatch in the PR description: the summary says guard v0.1.1, but go.mod pins v0.1.2, which is also the version the compatibility section describes.
Security Issues
None found.
Correctness Issues
None found.
Suggestions
None.
Resolved prior findings
New throws away the underlying Firebase init errors (connector.go:66-75) is obsolete as a defect. The new comment at connector.go:73-74 records why: Firebase's signer error can include the private key. Keeping the message generic is the right security choice, so this is no longer a finding.---
Reviewed commit: 7915c52ef180
<!-- review-state: {"last_reviewed_sha": "7915c52ef180b7eb03b1eac47bac3b88ea7c2331", "base_sha": "fba77b1f295fbdefa5d86ff99bfbd94d37839886", "workflow_ref": "ConductorOne/github-workflows/.github/workflows/pr-review.yaml@refs/heads/main", "run_id": "44606333099", "run_attempt": "1", "summary_marker": "### Connector PR Review:", "verdict_mode": "baseline", "publication": "completed", "started_at": "2026-11-19T20:13:02Z", "working_comment_id": 7020970998, "working_comment_updated_at": "2026-11-19T20:14:11Z"} -->
No blocking issues found — see the full review report
<!-- review-publication: {"run_id": "44606333099", "run_attempt": "1", "workflow_ref": "ConductorOne/github-workflows/.github/workflows/pr-review.yaml@refs/heads/main", "summary_marker": "### Connector PR Review:", "verdict_mode": "baseline", "report_comment_id": 7020999199} -->
This fails if the path is a symlink, which I think is too restrictive for anyone running the connector in one shot or service mode.
pquerna
Summary
Replace Firebase's direct
WithCredentialsFileloader with a bounded local file read andgoogle-credential-guardv0.1.2. Only validated service-account JSON reaches the typed Google credential option. Pass an explicit Firebase config soFIREBASE_CONFIGcannot cause a second implicit file read. Credential parsing errors do not echo the path or key material.The configured path is documented as a local CLI/environment setting. Hosted launchers must independently keep tenants from choosing server-local paths or move to uploaded bytes. Guard adoption refreshes vendored Google auth/API dependencies. Two scoped lint notes preserve the existing legacy user-trait profile and status behavior; a separate migration can change those consumers deliberately.
Verification
FIREBASE_CONFIGpath set.go test -mod=vendor ./... -count=1passed in the direct checkout.make lintpassed with zero issues;git diff --checkpassed.No live Firebase provider credential, hosted launcher, or deployed runtime was exercised.
Credential format compatibility
Guard v0.1.2 accepts the two exact service-account token URIs in Google's current key examples and RSA PKCS#8 or PKCS#1 keys. It canonicalizes both URI forms to the pinned oauth2.googleapis.com endpoint and PKCS#1 to PKCS#8 before SDK use. OAuth authorized_user, external-account federation, unknown fields and non-string values remain intentionally unsupported; their admission requires a separately reviewed auth mode. Ordinary unknown field names are reported without echoing values.