agentleFS
iTwiniTwin/itwinjs-core/.github/skills/cve-remediation/SKILL.md

cve-remediation

Skill742 starsChanged 4 months agoMITView on GitHub

Domain knowledge for remediating CVEs in the iTwin.js Rush monorepo — pnpm-config.json structure, fix strategies, validation, and audit workflows.

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

12 rules. 0 are common, 5 are distinctive, and 7 are very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Always attempt fixes in this order.

    line 75
  2. Very specific:

    If the declaration uses catalog:<name>, update globalCatalogs.<name>[<dependency>] in pnpm-config.json and keep the manifest reference.

    line 84
  3. Very specific:

    Run rush update then rush audit to verify

    line 85
  4. Distinctive:

    If no safe version range exists, fall through to globalOverride (document why)

    line 86
  5. Very specific:

    Check existing overrides first: Before adding a new override, check if the package already has an entry in globalOverrides in …

    line 90
  6. Very specific:

    Semver range update (try first): Update the direct parent's version range, in its catalog entry if cataloged or its package.json otherwise, …

    line 91
  7. Very specific:

    Scoped globalOverride (last resort): Only if no safe parent version exists.

    line 92
  8. Very specific:

    Use rush-pnpm why <package> to trace transitive dependency paths when the audit output truncates them.

    line 94
  9. Distinctive:

    Only for non-production/dev-tooling risk.

    line 98
  10. Distinctive:

    After any remediation change:

    line 115
  11. Very specific:

    When direct dependency version ranges were changed in a package.json or a catalog entry:

    line 126
  12. Distinctive:

    After remediation, Rush requires changelog entries:

    line 136

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

CVE Remediation in iTwin.js

This skill covers the domain knowledge for fixing security vulnerabilities in the iTwin.js Rush monorepo. It is referenced by the CVE audit agent, the merge-conflict-resolving skill, and the backport-resolution skill.

Key Files

FilePurpose
common/config/rush/pnpm-config.jsonShared catalogs, global dependency overrides, and audit exceptions
common/config/rush/pnpm-lock.yamlResolved dependency tree (never manually edit)
common/config/rush/common-versions.jsonRush version-consistency policy (preferredVersions)
common/config/rush/repo-state.jsonAuto-generated repo state (commit after catalog or common-version changes)
<package>/package.jsonDirect dependency declarations: literal ranges or catalog:<name> references

pnpm-config.json Structure

This file has two conflict-prone sections:

globalOverrides

Forces specific dependency versions across the entire monorepo. Used when a transitive dependency cannot be updated via its parent's semver range.

{
  "globalOverrides": {
    "<package>": "<patched-version>",
    "<package>@<range>": "<patched-version>"
  }
}

Each override should include a trailing comment with:

  • The advisory URL (GHSA or CVE link)
  • The dependency path that pulls in the vulnerable package

Illustrative example (always consult the current common/config/rush/pnpm-config.json before editing):

"globalOverrides": {
  "rollup-plugin-copy>globby": "^11.0.0", // https://github.com/vladshcherbin/rollup-plugin-copy/issues/77
  "elliptic": "^6.6.1", // https://github.com/advisories/GHSA-vjh7-7g9h-fjfh crypto-browserify>browserify-sign>elliptic
  "fast-xml-parser": "^5.3.6", // https://github.com/advisories/GHSA-jmr7-xgp7-cmfj @google-cloud/storage > fast-xml-parser
  "axios@<1.0.0": "^1.13.5", // https://github.com/advisories/GHSA-43fc-jf86-j433
  "serialize-javascript": "^7.0.3" // https://github.com/advisories/GHSA-5c6j-r48x-rmvq mocha>serialize-javascript
}

Important: This file uses JSONC (JSON with comments). The last entry in any object/array must NOT have a trailing comma. When adding entries, ensure the previously-last entry gets a comma added and the new last entry does not have one.

ignoreCves (Audit Exceptions)

Located under a nested path. Used only for dev-tooling dependencies with no production path.

{
  "unsupportedPackageJsonSettings": {
    "pnpm": {
      "auditConfig": {
        "ignoreCves": [
          "CVE-XXXX-XXXXX" // https://advisory-url — dev-only reason
        ]
      }
    }
  }
}

Fix Strategy (Strict Order)

Always attempt fixes in this order. Do not skip to overrides without trying the earlier steps.

1. Classify: Direct vs Transitive

  • Direct: The vulnerable package is listed in a project's package.json
  • Transitive: The vulnerable package is pulled in by another dependency

2a. Direct Dependency Fix

  1. If the declaration uses catalog:<name>, update globalCatalogs.<name>[<dependency>] in pnpm-config.json and keep the manifest reference. Otherwise, update the version range in the affected package.json.
  2. Run rush update then rush audit to verify
  3. If no safe version range exists, fall through to globalOverride (document why)

2b. Transitive Dependency Fix

  1. Check existing overrides first: Before adding a new override, check if the package already has an entry in globalOverrides in pnpm-config.json to avoid conflicts or duplicates.
  2. Semver range update (try first): Update the direct parent's version range, in its catalog entry if cataloged or its package.json otherwise, to a version that resolves the transitive dep to a patched release.
  3. Scoped globalOverride (last resort): Only if no safe parent version exists. Scope the override to only the vulnerable version range (e.g., "lodash@>=4.0.0 <=4.17.23": "^4.18.0") rather than overriding all versions blanket. This avoids interfering with future already-patched versions. Document why in the override comment.

Use rush-pnpm why <package> to trace transitive dependency paths when the audit output truncates them.

3. ignoreCves (Absolute Last Resort)

Only for non-production/dev-tooling risk. Requires:

  • Explicit rationale in comment
  • Advisory link
  • Confirmation that the dependency has no production code path

Never ignore a Critical/High production-path CVE when a patch is available.

Severity Policy

SeverityAction
CriticalAlways fix or explicitly document blocker and risk
HighFix unless unacceptable breakage; if deferred, create tracking issue
Moderate/LowDefer and create tracking issue with recommendation

Validation Workflow

After any remediation change:

rush update                # Regenerate lock file
rush audit                 # Verify CVE is resolved (internally runs rush-pnpm audit --audit-level high)
rush build                 # Ensure no build breakage
rush test                  # Ensure no test regressions

Note: rush audit does not accept --level or --json flags directly. Use rush-pnpm why <package> to investigate specific dependency paths.

When direct dependency version ranges were changed in a package.json or a catalog entry:

rush extract-api           # Check for API surface changes

Skip extract-api only when the sole change is a globalOverride in pnpm-config.json.

Rush Change Files

After remediation, Rush requires changelog entries:

# Check if change files are needed
rush change --verify -b origin/<base-branch>

# If needed for internal dependency-only updates, create blank entries non-interactively
rush change --bulk --message "" --bump-type none -b origin/<base-branch>

Change files land in common/changes/@itwin/<package>/ as JSON files with unique filenames.

common-versions.json

If a direct dependency bump triggers Rush consistency errors, resolve any catalog reference before comparing its range with common/config/rush/common-versions.json. Keep the catalog and any literal preferred baseline coordinated, following common/config/rush/README-dependencies.md; do not replace catalog references with literals or add broad exceptions to silence a mismatch. Always commit the auto-generated common/config/rush/repo-state.json hash update alongside policy changes.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.