Category: RulesSemgrepMITv0.1.2

vuln-patterns

Semgrep rules taken from vulnerabilities that are already public. Tag v0.1.2 has 15 rules under rules/, covering C, Go, JavaScript, PHP, Python and Rust. The release has no archives: clone the tag and point Semgrep at the rules.

git clone --depth 1 --branch v0.1.2 https://github.com/ucsurf/vuln-patternssemgrep --config vuln-patterns/rules/ path/to/code

View on GitHubRelease v0.1.2

What it does

vuln-patterns is a Semgrep rule pack. The README says each rule comes from a vulnerability that is already public, links to the published report or GitHub advisory, and ships with positive (ruleid) and negative (ok) tests. Embargoed reports are not added.

The v0.1.2 tag contains 15 rule files under rules/. The README’s table covers C, Go, JavaScript, TypeScript, PHP, Python and Rust. The JavaScript rules in that table are also marked for TypeScript. The README says the rules are tested with Semgrep 1.183.0.

One name in the README’s table does not match the file at the tag. The table says sanitizer-output-mutated-after-clean. The file at v0.1.2 is rules/python/xss/bleach-clean-then-unescape.yaml. The README’s sample output reports the rule id rules.python.xss.sanitizer-output-mutated-after-clean on a four-line program that calls html.unescape on the result of bleach.clean.

There is no install binary. The v0.1.2 GitHub release has no attached files. Clone the repository, or the tag, and pass rules/ to Semgrep. The license is MIT.

Limits

The README says the rules are pattern-based and mostly stay inside one procedure. A match is a lead to review, not proof of a vulnerability. A bug that passes through helper functions across files can be missed. Each rule covers the API shape from its source advisory (bleach and html, Prisma, ajv, templ and the others named in the table). Other libraries with the same bug class are not covered. Semgrep older than 1.183.0 may reject some syntax.

Usage

  1. Clone and scan, as the README shows it

    This clone follows the default branch. It does not pin v0.1.2.

    git clone --depth 1 https://github.com/ucsurf/vuln-patternssemgrep --config vuln-patterns/rules/ path/to/code
  2. Pin the v0.1.2 tag

    v0.1.2 is the latest tag. That GitHub release has no attached archives.

    git clone --depth 1 --branch v0.1.2 https://github.com/ucsurf/vuln-patternssemgrep --config vuln-patterns/rules/ path/to/code
  3. One rule from the v0.1.2 tag

    semgrep --config vuln-patterns/rules/go/crypto/pkcs7-first-cert-as-signer.yaml path/to/code
  4. GitHub Actions, pinned to v0.1.2 and Semgrep 1.183.0

    Copied from the README. The README says the rules are tested with Semgrep 1.183.0.

    jobs:
      vuln-patterns:
        runs-on: ubuntu-latest
        permissions: { contents: read }
        steps:
          - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
            with: { persist-credentials: false }
          - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
            with: { repository: ucsurf/vuln-patterns, ref: v0.1.2, path: .vuln-patterns, persist-credentials: false }
          - run: pipx run semgrep==1.183.0 --config .vuln-patterns/rules/ --error --metrics=off --exclude .vuln-patterns .
  5. pre-commit, using Semgrep’s own hook

    The README says to point this hook at a checkout of the rules, for example a git submodule at .vuln-patterns.

    repos:
      - repo: https://github.com/semgrep/pre-commit
        rev: v1.183.0
        hooks:
          - id: semgrep
            args: ["--config", ".vuln-patterns/rules/", "--error", "--metrics=off", "--skip-unknown-extensions"]

Machine-readable: JSON · Markdown · ID vuln-patterns

More tools

  • lockreview

    Reviews GitHub Actions lockfile (actions.lock) diffs and flags repository identity changes, impostor commits, ref rollbacks, new transitive actions, and runs/dist changes.

    ucsurf/lockreview
  • hookjack

    Static scanner for commands that AI assistants and IDEs run on their own when you open a repository.

    ucsurf/hookjack
  • disclose

    Finds where to report a vulnerability.

    ucsurf/disclose
  • repojack

    Finds dependencies that point at a deleted or renamed GitHub account, so someone else could register the name and serve that code.

    ucsurf/repojack
  • pwnreq

    Finds GitHub Actions workflows where someone without write access can run code that sees repository secrets: pwn requests and script injection.

    ucsurf/pwnreq