Skip to content

fix(security): remediate all open Trivy/CodeQL security findings#61

Merged
codywilliamson merged 3 commits intomainfrom
copilot/fix-security-issues
Apr 21, 2026
Merged

fix(security): remediate all open Trivy/CodeQL security findings#61
codywilliamson merged 3 commits intomainfrom
copilot/fix-security-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 16, 2026

Fixes all 16 open security-labelled issues from the repo-sentinel workflow in a single PR. Covers vulnerable transitive dependencies, non-root Dockerfile users, and one suppressed unfixable finding.

Dependency overrides (package.json + pnpm-lock.yaml)

Added pnpm.overrides to force all vulnerable transitive deps to their minimum patched versions. Old vulnerable versions are fully absent from the regenerated lockfile.

Package Before After Issues closed
yaml 2.8.2 2.8.3 Closes #58
vite 7.3.1 7.3.2 Closes #55 #56 #57
smol-toml 1.6.0 1.6.1 Closes #54
picomatch 4.0.3 4.0.4 Closes #52 #53
h3 1.15.5 1.15.11 Closes #48 #49 #50 #51
devalue 5.6.3 5.7.1 Closes #46
defu 6.1.4 6.1.7 Closes #45

Version bounds on vite (<8) and h3 (<2) are intentional — vitest@4 peers on vite@7, and unstorage requires h3@1.

Dockerfiles — non-root USER (DS-0002)

Both production stages now create a non-root system user (appuser, UID 1001) and switch to it before the entrypoint. Numeric UIDs used for portability.

.trivyignore — accepted unfixable finding

GHSA-67mh-4wv8-2f99 (esbuild@0.18.20):


  • Add pnpm.overrides to force patched versions of 7 vulnerable packages
  • Regenerate pnpm-lock.yaml — all old vulnerable versions removed
  • Add non-root USER (UID 1001) to docker/frontend.Dockerfile
  • Add non-root USER (UID 1001) to backend/Dockerfile
  • Create .trivyignore to suppress GHSA-67mh-4wv8-2f99 with rationale
  • Drop empty "Initial plan" commit that was failing commitlint
Original prompt

Please analyze ALL currently open GitHub issues with the security label in this repository (created by the repo-sentinel workflow). These come from Trivy and CodeQL scans.

Your task:

  1. Review every open security-labeled issue; group them by root cause where possible
  2. Fix the findings in a SINGLE pull request (one PR, not many)
  3. Use conventional-commit messages (e.g. fix(deps): bump xyz to patched version, fix: sanitize user input in X)
  4. For findings you believe are false positives or unfixable, document them in the PR description and propose a suppression strategy (e.g. Trivy .trivyignore, CodeQL suppression comment) rather than leaving them
  5. Close the corresponding issues via Closes #NN in the PR body
  6. Leave the PR ready for human review — do not merge

Prefer minimal, targeted fixes. Do not refactor unrelated code. Keep the diff focused on security remediation.

- fix(deps): add pnpm.overrides for yaml>=2.8.3, vite>=7.3.2<8,
  smol-toml>=1.6.1, picomatch>=4.0.4, h3>=1.15.9<2,
  devalue>=5.6.4, defu>=6.1.5 — regenerate pnpm-lock.yaml
- fix(docker): add non-root USER (uid 1001) to frontend production stage
- fix(docker): add non-root USER (uid 1001) to backend production stage
- chore: add .trivyignore to suppress GHSA-67mh-4wv8-2f99 (esbuild 0.18
  pinned by drizzle-kit, dev-only risk)

Closes #45 #46 #47 #48 #49 #50 #51 #52 #53 #54 #55 #56 #57 #58 #59 #60

Agent-Logs-Url: https://github.com/codywilliamson/shockstack/sessions/8bcf75b4-51ed-4892-a0d0-2bdc3ff399b5
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 16, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
shockstack 4a9040e Commit Preview URL

Branch Preview URL
Apr 21 2026, 04:13 AM

Copilot AI changed the title [WIP] Fix security issues identified by Trivy and CodeQL fix(security): remediate all open Trivy/CodeQL security findings Apr 16, 2026
Copilot AI requested a review from codywilliamson April 16, 2026 16:56
@codywilliamson codywilliamson marked this pull request as ready for review April 16, 2026 17:02
Copilot AI review requested due to automatic review settings April 16, 2026 17:02
@codywilliamson
Copy link
Copy Markdown
Owner

@copilot address commitlint issues.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR remediates repo-sentinel security findings by forcing patched transitive dependency versions via pnpm overrides, switching Docker production images to run as a non-root user, and suppressing one dev-only/unfixable Trivy advisory.

Changes:

  • Add pnpm.overrides to enforce patched versions of vulnerable transitive dependencies and regenerate pnpm-lock.yaml.
  • Update frontend and backend Dockerfiles to create/use a non-root user in production stages.
  • Introduce .trivyignore to suppress a documented, dev-only, currently unfixable GHSA.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pnpm-lock.yaml Captures dependency resolutions consistent with new pnpm overrides.
package.json Adds pnpm.overrides to force patched transitive dependency versions.
docker/frontend.Dockerfile Creates a non-root user and runs the production container as that user.
backend/Dockerfile Creates a non-root user and runs the production container as that user.
.trivyignore Suppresses a specific Trivy finding with rationale for deferral.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread .trivyignore
# 0.18 and 0.25.
# Risk: Dev-only; esbuild's dev server is never run in CI or production.
# The advisory affects the `serve` API, which drizzle-kit does not invoke.
# Review: re-evaluate when drizzle-kit drops @esbuild-kit or publishes a fix.
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

This .trivyignore header states that all entries must include a rationale and a review date, but the suppression block does not include an actual review date. Add a concrete date (e.g. Review: YYYY-MM-DD) so the suppression has a clear re-evaluation point and matches the documented policy.

Suggested change
# Review: re-evaluate when drizzle-kit drops @esbuild-kit or publishes a fix.
# Review: 2026-01-15 — re-evaluate when drizzle-kit drops @esbuild-kit or publishes a fix.

Copilot uses AI. Check for mistakes.
Comment on lines 24 to +26
COPY --from=build /app/frontend/dist /app/dist
COPY --from=build /app/frontend/package.json /app/
RUN chown -R appuser:appgroup /app
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

RUN chown -R ... /app adds an extra layer and can be slow on larger build contexts. You can avoid the recursive chown by using COPY --chown=appuser:appgroup ... for the two COPY instructions (after creating the user), which is typically faster and produces smaller images.

Suggested change
COPY --from=build /app/frontend/dist /app/dist
COPY --from=build /app/frontend/package.json /app/
RUN chown -R appuser:appgroup /app
COPY --from=build --chown=appuser:appgroup /app/frontend/dist /app/dist
COPY --from=build --chown=appuser:appgroup /app/frontend/package.json /app/

Copilot uses AI. Check for mistakes.
Comment on lines +27 to 29
USER appuser
EXPOSE 4321
CMD ["node", "./dist/server/entry.mjs"]
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

PR description mentions numeric UIDs for portability, but the image uses USER appuser (name-based). If numeric UID usage is required for the security policy/scanner, switch to USER 1001:1001 (or update the PR description if name-based is intended).

Copilot uses AI. Check for mistakes.
Comment thread backend/Dockerfile
Comment on lines 11 to +12
COPY --from=build /out .
RUN addgroup --gid 1001 --system appgroup && adduser --uid 1001 --system --ingroup appgroup appuser && chown -R appuser:appgroup /app
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

This stage copies files as root, then fixes ownership with chown -R. To reduce layers and build time, consider creating the user/group first and using COPY --chown=1001:1001 --from=build /out . (or equivalent) so you don’t need a recursive chown step.

Suggested change
COPY --from=build /out .
RUN addgroup --gid 1001 --system appgroup && adduser --uid 1001 --system --ingroup appgroup appuser && chown -R appuser:appgroup /app
RUN addgroup --gid 1001 --system appgroup && adduser --uid 1001 --system --ingroup appgroup appuser
COPY --chown=1001:1001 --from=build /out .

Copilot uses AI. Check for mistakes.
Comment thread backend/Dockerfile
Comment on lines +12 to 14
RUN addgroup --gid 1001 --system appgroup && adduser --uid 1001 --system --ingroup appgroup appuser && chown -R appuser:appgroup /app
USER appuser
EXPOSE 8080
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

PR description says numeric UIDs are used for portability, but the container switches with USER appuser (name-based). If numeric is important for runtime environments/scanners, prefer USER 1001:1001 here (or adjust the PR description to match the implementation).

Copilot uses AI. Check for mistakes.
Comment thread package.json
Comment on lines +61 to +67
"yaml": ">=2.8.3",
"vite": ">=7.3.2 <8",
"smol-toml": ">=1.6.1",
"picomatch": ">=4.0.4",
"h3": ">=1.15.9 <2",
"devalue": ">=5.6.4",
"defu": ">=6.1.5"
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

The new pnpm.overrides entries use open-ended >= ranges (e.g. yaml, smol-toml, picomatch, devalue, defu). This can allow future major-version upgrades during install, which can introduce breaking changes unexpectedly. Consider pinning to the patched version or adding an explicit upper bound (e.g. <next-major) for each override to keep installs deterministic and reduce risk.

Suggested change
"yaml": ">=2.8.3",
"vite": ">=7.3.2 <8",
"smol-toml": ">=1.6.1",
"picomatch": ">=4.0.4",
"h3": ">=1.15.9 <2",
"devalue": ">=5.6.4",
"defu": ">=6.1.5"
"yaml": ">=2.8.3 <3",
"vite": ">=7.3.2 <8",
"smol-toml": ">=1.6.1 <2",
"picomatch": ">=4.0.4 <5",
"h3": ">=1.15.9 <2",
"devalue": ">=5.6.4 <6",
"defu": ">=6.1.5 <7"

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 16, 2026

@copilot address commitlint issues.

The failure is caused by the empty c05b5dd Initial plan commit (auto-generated by the planning step with a non-conventional message). The commit-guard workflow checks every commit in the PR range, so it must be removed.

Fixing this requires a force-push to rewrite history. The report_progress tool only does regular fast-forward pushes — any local rebase gets undone when it re-syncs with origin before pushing. I'm not able to force-push through the available tooling.

To fix it, please run the following on the PR branch:

git fetch origin
git checkout copilot/fix-security-issues
git rebase -i 68038ae   # drop the "Initial plan" commit in the editor
git push --force-with-lease origin copilot/fix-security-issues

This will leave a single, clean fix(security): … commit that passes commitlint.

@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 1.15.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@codywilliamson codywilliamson deleted the copilot/fix-security-issues branch April 23, 2026 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment