Skip to content

chore(security): add security policy, dependabot config, and config key guards#1415

Merged
clay-good merged 9 commits into
mainfrom
chore/security-hardening
Jul 22, 2026
Merged

chore(security): add security policy, dependabot config, and config key guards#1415
clay-good merged 9 commits into
mainfrom
chore/security-hardening

Conversation

@clay-good

@clay-good clay-good commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Status: Approved, all checks green.

Answers #1414, where a user's security team rejected OpenSpec after running two scanners. Everything real is fixed, and the rest is documented so the next scan takes minutes to triage instead of a thread.

What changed

Dependencies. Every advisory affecting the published package is gone. One build-only advisory remains (ajv, pinned upstream by eslint). All of it was a stale lockfile — the fixes landed inside existing version ranges, so no declared dependency moved except @changesets/cli.

Two real bugs, neither found by their scanners.

  • openspec config set --allow-unknown __proto__.polluted x reported success and wrote onto Object.prototype. The flag was meant to relax the unknown-key check; it was skipping every key check.
  • The spec heading parser backtracked quadratically on a whitespace-padded heading: 10,000 characters took 60ms, 100,000 would take about six seconds.

Automation, so this does not recur. A SECURITY.md with a private disclosure path and an explicit threat model, Dependabot updates with a release cooldown, dependency review on every pull request, a scheduled audit, and all nine GitHub Actions pinned to commit SHAs.

Proof

The dependency claim is checkable in two commands:

npm install @fission-ai/openspec
ls node_modules | grep -E '^(vite|rollup|js-yaml|minimatch)$'   # no matches

We also ran the reporter's own scanner: 208 findings, and 201 of them are a single rule (path-join-resolve-traversal) firing on paths built from module constants, command-line arguments, or filenames from readdir. None takes untrusted input.

Check Result
Test suite 2168 pass
New parser vs the old one 303,000 generated inputs + all 634 repo markdown files, 0 mismatches
Packed tarball: install and openspec init works
CodeQL alerts in shipped source 5 → 0

Notes

  • sharp stays flagged in the docs site. next pins it exactly, and the site is a static export that never imports next/image, so the optimizer that uses it never runs.
  • flake.nix pins a hash over the whole dependency set, so any future lockfile change needs it repinned.
  • Still needs a repository admin: switching CodeQL to the security-extended query suite.

Refs #1414

🤖 Generated with Claude Code

@clay-good
clay-good requested a review from TabishB as a code owner July 22, 2026 15:33
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Configuration key paths now reject prototype-chain segments during validation and nested mutations, including with --allow-unknown. Heading parsing uses linear-time CommonMark-aware logic with edge-case and performance tests. Security policy, dependency automation, action pinning, audit workflows, and release metadata were added or updated.

Changes

Configuration path hardening

Layer / File(s) Summary
Prototype-chain path guards
src/core/config-schema.ts, src/commands/config.ts, test/core/config-schema.test.ts
Validation, CLI handling, and nested set/delete helpers reject __proto__, constructor, and prototype segments while preserving legitimate nested paths.
Dependency and release metadata
package.json, .changeset/harden-config-key-paths.md
The YAML dependency and Changesets CLI are updated, and a patch release documents the configuration hardening and YAML update.

Linear heading parsing

Layer / File(s) Summary
CommonMark heading parser
src/core/references.ts, test/core/references.test.ts, .changeset/linear-heading-parse.md
Purpose extraction uses hand-rolled heading parsing with closing-hash, whitespace, line-ending, and large-padding coverage.

Security operations and supply-chain controls

Layer / File(s) Summary
Security policy and auditing
SECURITY.md, .github/workflows/security.yml
Security reporting, threat-model boundaries, dependency review, and production/tooling audit jobs are defined.
Dependency and action update controls
.github/dependabot.yml, .github/workflows/ci.yml, .github/workflows/release-prepare.yml, flake.nix
Dependabot schedules, immutable action references, and the Nix dependency fetch hash are configured or updated.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: tabishb

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is clear and relevant to the PR’s main security-focused changes, including security policy, Dependabot, and config key hardening.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/security-hardening

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/core/config-schema.test.ts`:
- Around line 379-385: Add an assertion in the setNestedValue test for each
unsafe path that the target obj remains empty after the write attempt, while
retaining the existing Object.prototype pollution checks. Update only the test
named “setNestedValue leaves the prototype untouched for…” and verify it with
the specified Vitest command.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dfca805b-060a-474d-9363-b6f939a8ba2b

📥 Commits

Reviewing files that changed from the base of the PR and between 5dfef4b and ba890be.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • .changeset/harden-config-key-paths.md
  • .github/dependabot.yml
  • SECURITY.md
  • package.json
  • src/commands/config.ts
  • src/core/config-schema.ts
  • test/core/config-schema.test.ts

Comment on lines +379 to +385
it.each(unsafePaths)('setNestedValue leaves the prototype untouched for "%s"', (path) => {
const obj: Record<string, unknown> = {};
setNestedValue(obj, path, 'polluted');

expect(({} as Record<string, unknown>).polluted).toBeUndefined();
expect(Object.prototype).not.toHaveProperty('polluted');
});

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.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Assert that unsafe writes leave the target object unchanged.

The prototype assertions alone would still pass for some guard regressions that create own constructor/prototype properties. Assert obj remains empty too.

Proposed test strengthening
       setNestedValue(obj, path, 'polluted');

+      expect(obj).toEqual({});
       expect(({} as Record<string, unknown>).polluted).toBeUndefined();

Run pnpm exec vitest run test/core/config-schema.test.ts.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it.each(unsafePaths)('setNestedValue leaves the prototype untouched for "%s"', (path) => {
const obj: Record<string, unknown> = {};
setNestedValue(obj, path, 'polluted');
expect(({} as Record<string, unknown>).polluted).toBeUndefined();
expect(Object.prototype).not.toHaveProperty('polluted');
});
it.each(unsafePaths)('setNestedValue leaves the prototype untouched for "%s"', (path) => {
const obj: Record<string, unknown> = {};
setNestedValue(obj, path, 'polluted');
expect(obj).toEqual({});
expect(({} as Record<string, unknown>).polluted).toBeUndefined();
expect(Object.prototype).not.toHaveProperty('polluted');
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/core/config-schema.test.ts` around lines 379 - 385, Add an assertion in
the setNestedValue test for each unsafe path that the target obj remains empty
after the write attempt, while retaining the existing Object.prototype pollution
checks. Update only the test named “setNestedValue leaves the prototype
untouched for…” and verify it with the specified Vitest command.

Source: Coding guidelines

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@flake.nix`:
- Around line 53-54: Replace the empty hash in the fetchPnpmDeps configuration
with the valid pinned sha256 hash generated by running scripts/update-flake.sh.
Preserve fetcherVersion and commit the resulting sha256-... value so Nix build
and update validation can resolve dependencies.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cafa7e57-6fcf-43bc-9d20-44783bb508be

📥 Commits

Reviewing files that changed from the base of the PR and between ba890be and 5d673cf.

📒 Files selected for processing (1)
  • flake.nix

Comment thread flake.nix Outdated
@clay-good
clay-good force-pushed the chore/security-hardening branch from 5d673cf to 26600a8 Compare July 22, 2026 15:43
clay-good and others added 3 commits July 22, 2026 11:09
…ey guards

Adds a SECURITY.md with a private disclosure path and an explicit threat
model, a Dependabot configuration covering the CLI package, the docs site,
and CI actions, and closes a prototype-pollution path in `config set`.

`--allow-unknown` was meant to relax the known-key check but skipped every
key check, so `openspec config set --allow-unknown __proto__.polluted x`
reported success and assigned onto Object.prototype for the process
lifetime. Unsafe segments are now rejected at the command layer regardless
of `--allow-unknown`, and setNestedValue/deleteNestedValue refuse them for
any caller.

Also bumps the bundled yaml dependency from 2.8.2 to 2.9.0, the only
advisory in this repo that affects code shipped in the npm package.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
fetchPnpmDeps pins a fixed-output hash over the whole dependency set, so
changing pnpm-lock.yaml invalidates it. Recovered the new value from a
hash-mismatch build.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Refreshes both lockfiles so every open advisory in the CLI package is
resolved, replaces a quadratically-backtracking heading parser, and adds
the automation to catch the next one.

Dependency refresh (in-range, lockfile only): brace-expansion, flatted,
js-yaml, minimatch, postcss, rollup, and vite all move to patched versions
in the root lockfile; fast-uri and brace-expansion move in the website
lockfile. Only @changesets/cli needed a declared floor bump, to reach a
patched js-yaml. Production dependencies now report zero advisories.

extractFirstPurposeLine parsed ATX headings with /\s+#+\s*$/, which
backtracks quadratically on a whitespace-padded title. Replaced with a
linear hand-rolled scan, verified identical to the old implementation
across 303,000 generated inputs.

Automation: a Security workflow runs dependency review on pull requests,
blocks on advisories in published dependencies, and re-audits weekly; every
GitHub Action is pinned to a commit SHA so a moved tag cannot change what
CI executes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@clay-good
clay-good force-pushed the chore/security-hardening branch from 26600a8 to 89240c1 Compare July 22, 2026 16:10
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 22, 2026

Copy link
Copy Markdown

Deploying openspec-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 89240c1
Status: ✅  Deploy successful!
Preview URL: https://cc077a6b.openspec-docs.pages.dev
Branch Preview URL: https://chore-security-hardening.openspec-docs.pages.dev

View logs

clay-good and others added 2 commits July 22, 2026 11:12
Nothing is installed there, so setup-node's cache-save post step failed on
the missing store path even though both audit steps passed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/release-prepare.yml:
- Around line 27-30: Update the create-github-app-token step in the release
workflow to add explicit permission-* inputs limited to the permissions required
by checkout and Changesets, rather than inheriting the full installation grant.
Keep the existing app-id and private-key configuration unchanged and avoid
granting unrelated permissions.
- Around line 32-35: Disable credential persistence in the prepare checkout step
by setting persist-credentials to false in .github/workflows/release-prepare.yml
lines 32-35, then provide the GitHub App token explicitly to the
changesets/action step at lines 73-75 so only that step can push.

In @.github/workflows/security.yml:
- Around line 17-18: Update the dependency-review job in the security workflow
to grant pull-requests: write alongside the existing contents: read permission,
preserving comment-summary-in-pr: on-failure so failure summaries can be posted.

In `@src/core/references.ts`:
- Around line 79-125: Update parseHeadingTitle to accept up to three leading
spaces, recognize an opening hash run ending at the line boundary as a valid
empty heading, and reject four-or-more-space indentation. Replace the \s
delimiter checks used by parseHeadingTitle and stripClosingSequence with
spaces/tabs-only matching, while preserving closing-sequence behavior; add
regressions for empty, indented, and four-space-rejected ATX headings.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2cfbb5d8-944d-4974-9e89-afa1cb6fec39

📥 Commits

Reviewing files that changed from the base of the PR and between 26600a8 and 332fefe.

⛔ Files ignored due to path filters (2)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • website/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (14)
  • .changeset/harden-config-key-paths.md
  • .changeset/linear-heading-parse.md
  • .github/dependabot.yml
  • .github/workflows/ci.yml
  • .github/workflows/release-prepare.yml
  • .github/workflows/security.yml
  • SECURITY.md
  • flake.nix
  • package.json
  • src/commands/config.ts
  • src/core/config-schema.ts
  • src/core/references.ts
  • test/core/config-schema.test.ts
  • test/core/references.test.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • .github/dependabot.yml
  • test/core/config-schema.test.ts
  • flake.nix
  • src/core/config-schema.ts

Comment on lines +27 to 30
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}

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.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## release-prepare workflow\n'
cat -n .github/workflows/release-prepare.yml | sed -n '1,220p'

printf '\n## workflow references to create-github-app-token / checkout\n'
rg -n "create-github-app-token|actions/checkout|persist-credentials|permission-" .github/workflows -S

Repository: Fission-AI/OpenSpec

Length of output: 9997


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## action docs / README references in repo\n'
rg -n "create-github-app-token|persist-credentials|permission-.*inputs|checkout" -S .github README* docs* . 2>/dev/null | sed -n '1,220p'

Repository: Fission-AI/OpenSpec

Length of output: 31116


🌐 Web query:

actions/create-github-app-token permissions no permission-* inputs grants all available permissions

💡 Result:

The actions/create-github-app-token GitHub Action does not have a single input that automatically grants all available permissions to the generated token [1][2]. Instead, it uses a granular system where you can specify permissions using individual inputs prefixed with permission- (e.g., permission-issues: write, permission-pull-requests: read) [1][3]. By default, if you do not provide any permission-* inputs, the generated token automatically inherits all permissions currently granted to the GitHub App installation [1][3][4]. This default behavior effectively grants all permissions the app possesses, which is why the action recommends explicitly listing only the permissions required for your specific use case to follow the principle of least privilege [1][4]. If you were to manually list every available permission to mimic granting all permissions, you would need to define each required permission as a separate input in your workflow YAML [1][3]. Please note that requesting a permission in your workflow that the GitHub App installation itself does not have will result in an error [1][4][5].

Citations:


Limit the GitHub App token to the permissions this release needs.

Without any permission-* inputs, actions/create-github-app-token inherits every permission granted to the app installation. Narrow it to the small set this job actually uses, so checkout and Changesets don't get the full installation grant.

🧰 Tools
🪛 zizmor (1.26.1)

[error] 27-27: dangerous use of GitHub App tokens (github-app): app token inherits blanket installation permissions

(github-app)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/release-prepare.yml around lines 27 - 30, Update the
create-github-app-token step in the release workflow to add explicit
permission-* inputs limited to the permissions required by checkout and
Changesets, rather than inheriting the full installation grant. Keep the
existing app-id and private-key configuration unchanged and avoid granting
unrelated permissions.

Source: Linters/SAST tools

Comment on lines +32 to 35
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}

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.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE=".github/workflows/release-prepare.yml"

echo "== outline =="
ast-grep outline "$FILE" --view expanded || true

echo
echo "== relevant lines =="
nl -ba "$FILE" | sed -n '1,220p'

echo
echo "== checkout and git push references =="
rg -n "actions/checkout|git push|persist-credentials|token:|github.token|app-token|changeset|release" "$FILE"

Repository: Fission-AI/OpenSpec

Length of output: 286


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE=".github/workflows/release-prepare.yml"

echo "== file metadata =="
wc -l "$FILE"
echo

echo "== lines 1-140 =="
sed -n '1,140p' "$FILE" | nl -ba

Repository: Fission-AI/OpenSpec

Length of output: 279


🏁 Script executed:

#!/bin/bash
set -euo pipefail
FILE=".github/workflows/release-prepare.yml"
wc -l "$FILE"
sed -n '1,180p' "$FILE" | nl -ba
rg -n "actions/checkout|git push|persist-credentials|token:|github.token|app-token|changeset|release" "$FILE"

Repository: Fission-AI/OpenSpec

Length of output: 239


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE=".github/workflows/release-prepare.yml"

echo "== top of file (1-120) =="
sed -n '1,120p' "$FILE" | awk '{printf "%4d  %s\n", NR, $0}'

echo
echo "== bottom of file (121-220) =="
sed -n '121,220p' "$FILE" | awk '{printf "%4d  %s\n", NR+120, $0}'

echo
echo "== credential and push references =="
rg -n "actions/checkout|persist-credentials|git push|git config|token:|github.token|app-token|changeset|release" "$FILE"

Repository: Fission-AI/OpenSpec

Length of output: 10396


Disable credential persistence on the prepare checkout (.github/workflows/release-prepare.yml#L32-L35). The GitHub App token is only needed by changesets/action; leaving it in local git config exposes it to the later install/release steps. Set persist-credentials: false here and pass the token only to the step that pushes.

🧰 Tools
🪛 zizmor (1.26.1)

[warning] 32-35: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)

📍 Affects 1 file
  • .github/workflows/release-prepare.yml#L32-L35 (this comment)
  • .github/workflows/release-prepare.yml#L73-L75
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/release-prepare.yml around lines 32 - 35, Disable
credential persistence in the prepare checkout step by setting
persist-credentials to false in .github/workflows/release-prepare.yml lines
32-35, then provide the GitHub App token explicitly to the changesets/action
step at lines 73-75 so only that step can push.

Source: Linters/SAST tools

Comment on lines +17 to +18
permissions:
contents: read

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== workflow file =="
git ls-files .github/workflows/security.yml
echo
cat -n .github/workflows/security.yml | sed -n '1,220p'

echo
echo "== search for dependency-review-action usage =="
rg -n "dependency-review-action|comment-summary-in-pr|pull-requests: write|permissions:" .github/workflows -S

echo
echo "== candidate docs references in repo =="
rg -n "dependency-review-action|comment-summary-in-pr" -S .

Repository: Fission-AI/OpenSpec

Length of output: 3310


🌐 Web query:

actions/dependency-review-action comment-summary-in-pr pull-requests write permissions

💡 Result:

To use the comment-summary-in-pr feature in the actions/dependency-review-action, you must explicitly grant the pull-requests: write permission to your GitHub Actions workflow or job [1][2]. By default, the action does not post comments, and the comment-summary-in-pr setting is disabled (set to never) [1][3]. When enabled (by setting it to always or on-failure), the action requires write access to pull requests to create or update the summary comment [1][2]. With each execution, the action will overwrite the existing comment in the pull request [1][4]. You can configure these permissions in your workflow YAML file as follows [2][5]: permissions: contents: read pull-requests: write jobs: dependency-review: runs-on: ubuntu-latest steps: - name: Dependency Review uses: actions/dependency-review-action@v4 with: comment-summary-in-pr: always

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail
cat -n .github/workflows/security.yml | sed -n '1,220p'
rg -n "dependency-review-action|comment-summary-in-pr|pull-requests: write|permissions:" .github/workflows -S

Repository: Fission-AI/OpenSpec

Length of output: 3168


Grant pull-requests: write to dependency-review

comment-summary-in-pr: on-failure needs pull-requests: write; with only contents: read, the summary comment can't be posted. Add that permission on this job, or disable the summary.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/security.yml around lines 17 - 18, Update the
dependency-review job in the security workflow to grant pull-requests: write
alongside the existing contents: read permission, preserving
comment-summary-in-pr: on-failure so failure summaries can be posted.

Comment thread src/core/references.ts
Comment on lines +79 to +125
const WHITESPACE = /\s/;

/**
* Drop a CommonMark closing sequence (`## Purpose ##`). The closing run only
* counts when whitespace precedes it, so `Purpose###` keeps its hashes.
* Scans from the end so the cost stays linear in the title length.
*/
function stripClosingSequence(title: string): string {
let end = title.length;
while (end > 0 && WHITESPACE.test(title[end - 1])) {
end--;
}

const hashEnd = end;
while (end > 0 && title[end - 1] === '#') {
end--;
}

const noClosingRun = end === hashEnd;
const missingLeadingSpace = end === 0 || !WHITESPACE.test(title[end - 1]);
if (noClosingRun || missingLeadingSpace) {
return title.trim();
}

return title.slice(0, end).trim();
}

/**
* Heading title, or null when the line is not an ATX heading. Hand-rolled
* rather than a regex so a title padded with whitespace cannot backtrack.
*/
function parseHeadingTitle(line: string): string | null {
let level = 0;
while (level < 6 && level < line.length && line[level] === '#') {
level++;
}
if (level === 0 || level >= line.length || !WHITESPACE.test(line[level])) {
return null;
}

let start = level;
while (start < line.length && WHITESPACE.test(line[start])) {
start++;
}

return stripClosingSequence(line.slice(start));
}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Recognize empty and indented ATX headings.

## returns null, and ## Purpose is rejected, although both are valid CommonMark ATX headings. An empty heading inside Purpose therefore fails to terminate the section and can leak following text as the summary. Support end-of-line after the opening run, up to three leading spaces, and use only spaces/tabs—not \s—for ATX delimiters; add regressions including four-space rejection. (spec.commonmark.org)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/core/references.ts` around lines 79 - 125, Update parseHeadingTitle to
accept up to three leading spaces, recognize an opening hash run ending at the
line boundary as a valid empty heading, and reject four-or-more-space
indentation. Replace the \s delimiter checks used by parseHeadingTitle and
stripClosingSequence with spaces/tabs-only matching, while preserving
closing-sequence behavior; add regressions for empty, indented, and
four-space-rejected ATX headings.

clay-good and others added 3 commits July 22, 2026 11:42
…permission gap

Ran opengrep against the repository to check the claims in #1414. Of 208
findings, 201 are one path-traversal rule firing on joins built from module
constants, argv, or readdir entry names; 1 non-literal-regexp is fed only by
LEGACY_SLASH_COMMAND_PATHS. Neither is reachable from untrusted input. The
actionable results are applied here.

- dependabot: add a cooldown so a freshly published version is not adopted
  immediately. Security updates ignore the cooldown, so this delays only
  routine bumps, long enough for a compromised release to be yanked.
- getNestedValue now refuses prototype-reaching segments, matching the
  guards already on setNestedValue and deleteNestedValue.
- dependency-review no longer asks to comment on the pull request. That
  needs `pull-requests: write`, which the workflow does not grant and a
  fork's token never gets, so a real finding would have failed on the
  comment instead of reporting the vulnerable dependency.
- SECURITY.md: show the command that proves build tooling is absent from an
  installed copy, rather than asking readers to take it on trust.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Dependabot rejected the whole config file, which would have silently
disabled every version update.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The published-dependency audit no longer fails the job. A newly published
advisory should not block an unrelated pull request, and the step depends on
registry availability; Dependabot alerts and dependency review remain the
gates. SECURITY.md is corrected to match — it claimed the audit was blocking.

Also documents what the CLI does on your machine, all verified rather than
asserted: the install script prints one line and makes no network request or
file write; every shell-invoking call uses a fixed literal while anything
carrying user input uses an argument array with shell:false; telemetry sends
a command name, a version, and a local random UUID, with IP capture disabled.

Secret scanning is now listed, confirmed enabled by a repository admin.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@alfred-openspec alfred-openspec left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The runtime hardening looks sound, but the final commit makes pnpm audit --prod non-blocking on every event. Please keep it advisory on pull requests if desired while making scheduled and main/push production audits blocking, otherwise a newly published high-severity runtime advisory cannot fail any security run unless a dependency changes.

Making the step advisory on every event meant a newly published
high-severity advisory in a shipped dependency could not fail any run
unless a dependency changed. It stays advisory on pull requests, so an
unrelated change is never blocked by an advisory published that morning,
and blocks on the weekly schedule and on pushes to main, where a failure
is the signal rather than a tax on someone else's work.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@alfred-openspec alfred-openspec left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at exact head af523218. The production audit is now advisory only on pull requests and blocking on scheduled, push, and manual runs; the documentation matches, pnpm audit --prod is clean, and the full exact-head CI/security matrix passes.

@clay-good
clay-good added this pull request to the merge queue Jul 22, 2026
Merged via the queue into main with commit e2f748c Jul 22, 2026
16 checks passed
@clay-good
clay-good deleted the chore/security-hardening branch July 22, 2026 19:01
pull Bot pushed a commit to ben-vargas/ai-openspec that referenced this pull request Jul 22, 2026
…ee them (Fission-AI#1425)

* fix(config): guard prototype keys at the write, not behind a helper

The guards added in Fission-AI#1415 are effective — Object.prototype is never
touched — but they sit at the top of the function and delegate to a Set
lookup, which CodeQL cannot follow. Three prototype-pollution alerts stayed
open on src/core/config-schema.ts after that PR merged, on exactly the code
it hardened.

Each key segment is now compared literally in the loop that performs the
write. Same behavior for every input, including the empty path and nested
creation; the check is simply local to the danger and visible to a reader
and to the analyzer.

Also tightens a feedback test that matched the issue URL with a substring,
which CodeQL rated high. It now parses the URL and compares origin and
pathname, so a lookalike host cannot satisfy the assertion.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(config): validate the whole key path before writing

The first attempt at making the guard analyzer-visible moved the check
into the write loop, which changed behavior: a path whose unsafe segment
came after a safe one created the intermediate objects for the safe prefix
before bailing out. `setNestedValue({a:'x'}, 'b.constructor.c', v)` left
behind `b: {}` where the previous implementation wrote nothing.

A differential run against the implementation on main caught it — 47,782
mismatches in 400,000 cases. The literal comparisons stay, but they now
scan the whole path before any mutation, so a rejected key leaves the
object untouched. Re-run of the same comparison: 0 mismatches.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test(config): pin the partial-write behavior of a rejected key path

The fix landed without a test that would fail if the guard moved back into
the write loop, so the regression could return unnoticed. The existing
prototype-pollution tests only assert Object.prototype, and every path they
use starts with an unsafe segment on an empty object, so no intermediate
object is created before the guard trips.

Adds cases that put the unsafe segment after a safe one and assert the
whole target, plus one for a trailing unsafe segment, where the debris is a
re-parented prototype rather than an extra key and a structural comparison
alone would miss it.

Verified by reintroducing the regression: 5 of the new assertions fail
against the buggy build and pass against the fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants