Skip to content

Add Pinecone API key detector#4917

Merged
camgunz merged 5 commits into
mainfrom
feat/pinecone-detector
May 7, 2026
Merged

Add Pinecone API key detector#4917
camgunz merged 5 commits into
mainfrom
feat/pinecone-detector

Conversation

@dylanTruffle

@dylanTruffle dylanTruffle commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Adds a new detector for Pinecone vector database API keys (pcsk_* format).

Detection:

  • Regex matches the pcsk_{label}_{secret} structure with tight bounds (5–6 char label, exactly 63 char secret, word boundaries), verified against real keys. This minimizes false positives and prevents over-reading when a key is adjacent to other alphanumeric text.
  • The label is captured as a regex group and surfaced as ExtraData["key_id"] unconditionally, which maps to the key entry in the Pinecone console and aids revocation.
  • SecretParts["key"] is populated on every result, satisfying the framework's checksecretparts static check.

Verification:

  • Uses GET https://api.pinecone.io/indexes (non-state-changing, read-only) with Api-Key header auth and X-Pinecone-Api-Version: 2025-10.
  • Validates response body structure (requires the top-level "indexes" JSON key), not just status codes, to be resilient against generic 200 responses from intermediate proxies.
  • 200: Verified. Extracts project_id from the first index host, total_indexes, and metadata for up to 5 indexes (name, host, cloud, region).
  • 401: Invalid key. Returned unverified with no VerificationError (documented behavior).
  • 403: Valid key with restricted permissions (e.g. DataPlane-only roles). Marked as verified with permission=restricted metadata. Not documented in Pinecone's official API reference but observed in practice, since API keys can be created with custom permission scopes.
  • 500 / other: Indeterminate. Returned unverified with a VerificationError so callers can retry.

Uses common.SaneHttpClient() with standard timeouts and io.LimitReader (1 MiB cap) on the response body. The verification endpoint is hardcoded (api.pinecone.io/indexes), so there is no user-controlled destination and the hardened no-local-addresses client is not needed. No SDK dependencies.

Tests:

  • pinecone_test.go: regex coverage (valid/invalid shapes including too-short label, trailing alphanumerics, multi-key strings) plus table-driven tests for extractProjectID and mock-transport tests for verifyMatch (success, malformed indexes key, invalid indexes payload, metadata preservation on verification error).
  • pinecone_integration_test.go (//go:build detectors): live-credential coverage for verified, unverified, not-found, timeout, and unexpected-API-surface cases.

Registered as DetectorType Pinecone = 1048.

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?
image
image

Note

Medium Risk
Adds a new detector with outbound verification requests to Pinecone’s API; while scoped and read-only, mistakes could impact scan performance or verification accuracy via false positives/negatives.

Overview
Adds a new pinecone detector that identifies pcsk_... Pinecone API keys with a tightly-bounded regex, emits ExtraData["key_id"] and SecretParts, and optionally verifies keys by calling GET https://api.pinecone.io/indexes.

Verification now interprets 200/401/403 responses (including treating 403 as verified but permission-restricted), parses index metadata for extra context, and guards against malformed 200 bodies. The detector is registered in defaults and a new DetectorType_Pinecone enum value is added, with unit + integration tests covering pattern matching and verification edge cases.

Reviewed by Cursor Bugbot for commit 9d4cb70. Bugbot is set up for automated code reviews on this repo. Configure here.

@dylanTruffle dylanTruffle requested review from a team April 23, 2026 17:08
@dylanTruffle dylanTruffle requested a review from a team as a code owner April 23, 2026 17:08
@CLAassistant

CLAassistant commented Apr 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2295aba. Configure here.

Comment thread pkg/detectors/pinecone/pinecone.go
@dustin-decker dustin-decker force-pushed the feat/pinecone-detector branch from 2295aba to 111a28b Compare April 24, 2026 15:57

@MuneebUllahKhan222 MuneebUllahKhan222 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.

Nice work, especially the handling of ExtraData. LGTM. 🚀

@MuneebUllahKhan222

Copy link
Copy Markdown
Contributor

This PR also closes issue-4641.🎯

@shahzadhaider1 shahzadhaider1 linked an issue Apr 27, 2026 that may be closed by this pull request
@shahzadhaider1 shahzadhaider1 added the review/product-eng Team integrations reviewed, awaiting product-eng review label Apr 27, 2026
Dylan Ayrey and others added 3 commits May 4, 2026 18:44
Adds a new detector for Pinecone vector database API keys (pcsk_* format).

Detection:
- Regex matches the pcsk_{key_id}_{secret} structure with tight bounds
  (4+ char key ID, 40+ char secret, word boundaries) to minimize false positives.
- Extracts the embedded key_id from the token unconditionally, which maps to
  the key entry in the Pinecone console and aids revocation.

Verification:
- Uses GET /indexes (non-state-changing, read-only) with Api-Key header auth.
- Validates response body structure (requires "indexes" JSON key), not just
  status codes, to be resilient against API changes.
- 200: Verified. Extracts project_id from index host, total_indexes, and
  metadata for up to 5 indexes (name, host, cloud, region).
- 401: Invalid key (handles both plain text and JSON error bodies).
- 403: Valid key with restricted permissions (DataPlane-only roles).
  Marked as verified with permission=restricted metadata.

Uses common.SaneHttpClient() with standard timeouts (5s response, 2s dial,
3s TLS) and io.LimitReader (1MB cap) on response body. No SDK dependencies.

Registered as DetectorType Pinecone = 1048.

Made-with: Cursor
Migrate Pinecone verification metadata to SecretParts, address the redundant 200-response JSON parsing Bugbot flagged, and add focused regression coverage for malformed verification responses.
@shahzadhaider1 shahzadhaider1 force-pushed the feat/pinecone-detector branch from 59b36cf to 7e19313 Compare May 4, 2026 13:45
@camgunz camgunz merged commit ba0a524 into main May 7, 2026
16 checks passed
@camgunz camgunz deleted the feat/pinecone-detector branch May 7, 2026 10:10
MuneebUllahKhan222 pushed a commit that referenced this pull request May 29, 2026
* Add Pinecone API key detector

Adds a new detector for Pinecone vector database API keys (pcsk_* format).

Detection:
- Regex matches the pcsk_{key_id}_{secret} structure with tight bounds
  (4+ char key ID, 40+ char secret, word boundaries) to minimize false positives.
- Extracts the embedded key_id from the token unconditionally, which maps to
  the key entry in the Pinecone console and aids revocation.

Verification:
- Uses GET /indexes (non-state-changing, read-only) with Api-Key header auth.
- Validates response body structure (requires "indexes" JSON key), not just
  status codes, to be resilient against API changes.
- 200: Verified. Extracts project_id from index host, total_indexes, and
  metadata for up to 5 indexes (name, host, cloud, region).
- 401: Invalid key (handles both plain text and JSON error bodies).
- 403: Valid key with restricted permissions (DataPlane-only roles).
  Marked as verified with permission=restricted metadata.

Uses common.SaneHttpClient() with standard timeouts (5s response, 2s dial,
3s TLS) and io.LimitReader (1MB cap) on response body. No SDK dependencies.

Registered as DetectorType Pinecone = 1048.

Made-with: Cursor

* Align Pinecone detector with SecretParts

Migrate Pinecone verification metadata to SecretParts, address the redundant 200-response JSON parsing Bugbot flagged, and add focused regression coverage for malformed verification responses.

* Refactor Pinecone detector and add tests

---------

Co-authored-by: Dylan Ayrey <dylan@Dylans-MacBook-Pro.local>
Co-authored-by: Dustin Decker <dustin@trufflesec.com>
Co-authored-by: Shahzad Haider <shahzadhaider.se@gmail.com>
Co-authored-by: Shahzad Haider <76992801+shahzadhaider1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review/product-eng Team integrations reviewed, awaiting product-eng review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PINECONE detector

7 participants