Skip to content

Add DLP rules for Stripe and LLM-provider API keys #4

Closed

Description

@blitzcrieg1

Agents frequently handle Stripe (sk_live_...) and LLM-provider keys (OpenAI sk-..., Anthropic sk-ant-...). These leaking into a tool call is exactly what DLP is for.

Task

Add rules to apps/orchestrator/agentmetry/policies/dlp/manifest.yaml for Stripe live/test keys ((?i)sk_(live|test)_[0-9a-z]{24,}) and a generic provider key (sk-[a-zA-Z0-9]{20,}). Category credentials, severity critical.

Acceptance criteria

  • Fires + near-miss tests in test_dlp_scanner.py with fake keys (gitleaks:allow).
  • pytest green.

Activity

  1. added
    good first issue
    dlp-rule
    on Jul 14, 2026
  2. hvadlamani1 commented on Jul 28, 2026

    @hvadlamani1
    Contributor

    Hello! Can I be assigned to this?

  3. blitzcrieg1 commented on Jul 28, 2026

    @blitzcrieg1
    OwnerAuthor

    Assigned — thanks for picking this up, and welcome.

    Two things worth knowing before you start, both of which have bitten me in this
    exact file.

    1. The proposed generic pattern misses Anthropic keys.

    sk-[a-zA-Z0-9]{20,} needs 20+ alphanumerics immediately after sk-. An
    Anthropic key looks like sk-ant-api03-..., so the regex gets ant, hits the
    hyphen, and stops. Three characters, no match — despite the issue naming
    Anthropic explicitly. Worth handling sk-ant- as its own rule, or allowing
    hyphens in the generic one. Your call which reads better; I'd lean toward a
    separate anthropic_api_key rule, since a distinct rule id is more useful in a
    detection than a generic one.

    2. Patterns are matched against json.dumps(arguments), not raw text.

    This is the trap. By the time the scanner sees your pattern, quotes have been
    escaped, so a key inside a quoted shell command arrives as \"sk_live_...\".
    That is why aws_secret_key in the manifest has \\\\? before each quote —
    it survives the JSON escaping. If a rule works in a regex tester and not in the
    test suite, this is almost always why.

    Where things live

    • Rules: policies/dlp/manifest.yaml (see aws_access_key for the shape)
    • Tests: apps/orchestrator/tests/test_dlp_scanner.py
    • Run: cd apps/orchestrator && pytest tests/test_dlp_scanner.py -q

    On the tests

    Please write the near-miss alongside the positive. The aws_secret_key comment
    in the manifest explains why: a bare 40-char pattern matched every git commit
    SHA, so git checkout <sha> became a critical finding and, in block mode, a
    denied tool call. A false positive in a security tool is not cosmetic — it is
    how the feed gets muted. For these rules the near-misses I would want covered
    are a Stripe-shaped string that is too short, and something like sk- followed
    by a short word.

    CI runs gitleaks, so mark your fake keys with a gitleaks:allow comment or the
    secret scan will block the PR.

    One admin note: there is a CLA to sign for first contributions. You
    keep copyright; it grants permission to ship your work under Apache 2.0.

    Shout if anything is unclear or the escaping fights you.

  4. blitzcrieg1 commented on Aug 3, 2026

    @blitzcrieg1
    OwnerAuthor

    Heads up, the DLP manifest moved on master:

    policies/dlp/manifest.yaml                        (old)
    apps/orchestrator/agentmetry/policies/dlp/manifest.yaml   (new)
    

    Nothing about the task changes, only the path. I have updated the issue body above.

    Why it moved: those manifests are configuration the package needs in order to run, and pip install agentmetry was shipping without them. DLP scanning was silently inert for anyone who installed instead of cloning, which is close to the worst possible failure for a secret scanner. They now live inside the package so the wheel actually carries them.

    If you already have a branch open, it was a plain git mv, so a rebase on master should carry your edits across:

    git fetch origin && git rebase origin/master

    The test file is unchanged at apps/orchestrator/tests/test_dlp_scanner.py, though the constant at the top of it now points at the new location.

    Sorry for the churn, and thanks for picking this up.

  5. hvadlamani1 commented on Aug 27, 2026

    @hvadlamani1
    Contributor

    @blitzcrieg1, any update on the PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

dlp-rulegood first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions