Skip to content

Security hardening: demo fix, overflow guard, SECURITY.md, CodeQL, CI pinning#16

Merged
Alpaq92 merged 4 commits into
masterfrom
security-hardening-and-fixes
Jul 6, 2026
Merged

Security hardening: demo fix, overflow guard, SECURITY.md, CodeQL, CI pinning#16
Alpaq92 merged 4 commits into
masterfrom
security-hardening-and-fixes

Conversation

@Alpaq92

@Alpaq92 Alpaq92 commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix the xterm.js viewport's hardcoded black background showing through as a bar under the terminal in light mode (demo only).
  • Guard EncryptInternal's ciphertext-length calculation against 32-bit overflow with checked(...), matching the existing convention already used for the build-buffer growth path; documented the new threshold in the README.
  • Add SECURITY.md (supported versions, private vulnerability reporting, scope).
  • Add a CodeQL workflow for the C# surface (push/PR to master + weekly schedule).
  • Add explicit least-privilege permissions: contents: read to ci.yml and build-platform-tfms.yml.
  • Pin every third-party GitHub Action across all workflows to the commit SHA the currently-pinned tag resolves to (behavior-identical, just immutable).

Test plan

  • All workflow YAML re-validated with a YAML parser after the SHA-pinning edits.
  • Confirm ci.yml and the new codeql.yml both go green on this PR before merging.
  • Verified the overflow-guard change matches an existing checked(...) pattern already in the same file.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added automated code analysis in CI to help catch issues earlier.
    • Added a published security policy with guidance for reporting vulnerabilities.
  • Bug Fixes

    • Improved handling of very large text inputs to avoid overflow-related failures.
    • Refined the demo terminal’s appearance so it better matches light and dark themes.
  • Documentation

    • Clarified the library’s memory limits and large-input behavior.
  • Chores

    • Updated build and release automation to use more specific, stable action references.
    • Tightened workflow permissions for safer automation.

Alpaq92 and others added 3 commits July 6, 2026 21:54
…r in light mode

xterm.css hardcodes background-color: #000 on .xterm-viewport and never
re-syncs it to the theme passed into the Terminal constructor. The
terminal's text rows only cover a whole number of cell rows, so the strip
between the last row and the container's bottom edge showed that
un-themed black viewport through as a black bar in light mode.
#terminal .xterm-viewport already themed the scrollbar; it now also sets
background-color: var(--bg) so the viewport follows the page theme in
both modes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…uffers

EncryptInternal computed byteLen = plain.Length * 2 unchecked, while the
build-buffer growth path a few hundred lines up already wraps the
identical doubling in checked(...). A plaintext at or beyond
int.MaxValue / 2 UTF-16 chars would overflow byteLen to a negative or
too-small value, under-allocating the buffer the encryption then writes
into. Wrapped the multiplication in checked(...) to match the existing
convention, so construction now throws OverflowException instead of
risking a truncated allocation.

README: documented the new threshold and behavior in the Memory
footprint section.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ege hardening

- Add SECURITY.md: supported-versions policy, private-vulnerability-
  reporting instructions (already referenced from CONTRIBUTING.md but
  never actually written down), response expectations, and an explicit
  scope section deferring to the README's documented limitations.
- Add codeql.yml: CodeQL analysis for the C# surface on push/PR to
  master plus a weekly schedule, scoped to net10.0 on ubuntu-latest via
  the same CI_TFMS mechanism ci.yml's ubuntu leg already uses (no extra
  workloads needed).
- ci.yml and build-platform-tfms.yml previously had no explicit
  permissions: block, so they ran under whatever the repo/org default
  GITHUB_TOKEN scope happened to be. Both only build/test, so they now
  explicitly declare contents: read.
- Pin every third-party Action (actions/checkout, actions/setup-dotnet,
  actions/upload-pages-artifact, actions/deploy-pages,
  dependabot/fetch-metadata, googleapis/release-please-action) to the
  commit SHA the currently-pinned tag resolves to, with a trailing
  "# vN" comment for readability. Tags are mutable; a compromised action
  maintainer could re-point one without Dependabot noticing until the
  next real release. Behavior is unchanged - same version, just an
  immutable reference. Dependabot already tracks the github-actions
  ecosystem, so it can still propose SHA bumps going forward.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Alpaq92, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 294c92f9-bb1c-448c-be61-f1ee01e2a74c

📥 Commits

Reviewing files that changed from the base of the PR and between 9b9da50 and 7244aaa.

📒 Files selected for processing (1)
  • .github/workflows/codeql.yml
📝 Walkthrough

Walkthrough

This PR pins GitHub Actions to commit SHAs and adds explicit permissions across build, CI, dependabot, pages, and release workflows; adds a new CodeQL analysis workflow; adds SECURITY.md; fixes an integer overflow guard in ProtectedString's encryption length calculation with matching README documentation; and adjusts demo Wasm terminal CSS.

Changes

CI/CD workflow hardening and CodeQL

Layer / File(s) Summary
Pin actions and add permissions
.github/workflows/build-platform-tfms.yml, .github/workflows/ci.yml, .github/workflows/dependabot-auto-merge.yml, .github/workflows/pages.yml, .github/workflows/release.yml
Adds explicit contents: read permissions blocks and pins actions/checkout, actions/setup-dotnet, dependabot/fetch-metadata, actions/upload-pages-artifact, actions/deploy-pages, and release-please-action to commit SHAs instead of floating tags.
New CodeQL workflow
.github/workflows/codeql.yml
Adds a CodeQL analysis workflow for C# triggered on push/PR to master and weekly, with build/restore steps and CodeQL init/analyze steps.

Security policy documentation

Layer / File(s) Summary
SECURITY.md policy
SECURITY.md
Adds sections for supported versions, private vulnerability reporting, response expectations, and in/out-of-scope areas.

Plaintext length overflow guard and demo UI fix

Layer / File(s) Summary
Checked length arithmetic and docs
TopSecret.ProtectedString/ProtectedString.cs, README.md
Changes byteLen calculation in EncryptInternal to use checked arithmetic, throwing OverflowException on overflow; README documents the new guard and threshold.
Demo terminal viewport styling
TopSecret.Demo.Wasm/wwwroot/index.html
Adds explicit background-color to #terminal .xterm-viewport to match theme, with updated CSS comment.

Estimated code review effort: 2 (Simple) | ~12 minutes

Sequence Diagram(s)

Not applicable — changes are configuration pinning, documentation, and a small logic guard without multi-component interaction flows.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main security-focused changes: overflow protection, policy/docs, CodeQL, and workflow pinning.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch security-hardening-and-fixes

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.

@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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/codeql.yml:
- Around line 37-38: The Checkout step in the code scanning workflow is leaving
credentials persisted by default. Update the actions/checkout usage in the
workflow to explicitly disable credential persistence with persist-credentials
set to false, keeping the hardening consistent with the rest of the job; use the
Checkout step in codeql.yml as the place to make this change.
- Around line 25-27: The workflow-level permissions are too broad and should be
narrowed to the job that actually needs them. Move the `security-events: write`
permission from the top of the CodeQL workflow into the single job that uploads
results, and add a brief explanatory comment there so the least-privilege intent
is explicit. Use the existing workflow job definition in
`.github/workflows/codeql.yml` to scope `permissions` at the job level.
- Line 44: The workflow still pins github/codeql-action to the old major
version, so update both CodeQL action references in the CodeQL workflow from v3
to v4. Adjust the action versions used by the init and analyze steps so the
workflow consistently targets the supported v4 major line, keeping the existing
setup and step structure unchanged.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 1a0875d6-ec5c-4b38-a5ab-344f654526a4

📥 Commits

Reviewing files that changed from the base of the PR and between 9c30cfb and 9b9da50.

📒 Files selected for processing (10)
  • .github/workflows/build-platform-tfms.yml
  • .github/workflows/ci.yml
  • .github/workflows/codeql.yml
  • .github/workflows/dependabot-auto-merge.yml
  • .github/workflows/pages.yml
  • .github/workflows/release.yml
  • README.md
  • SECURITY.md
  • TopSecret.Demo.Wasm/wwwroot/index.html
  • TopSecret.ProtectedString/ProtectedString.cs

Comment thread .github/workflows/codeql.yml Outdated
Comment thread .github/workflows/codeql.yml
Comment thread .github/workflows/codeql.yml Outdated
- Set persist-credentials: false on the checkout step — this job never
  needs to push, so there's no reason to leave the token in the local
  git config for the rest of the job.
- Scope security-events: write (and contents: read) to the analyze job
  itself instead of the workflow-level default. Note: job-level
  permissions fully replace the workflow-level block rather than merging
  with it, so contents: read had to move down too, not just the
  security-events grant, or the job would have silently lost read access.
- Bump github/codeql-action from v3 to v4 (the current major per
  upstream's own README) on both the init and analyze steps, pinned to
  the new v4 tag's resolved commit SHA.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Alpaq92
Alpaq92 merged commit 0688074 into master Jul 6, 2026
7 checks passed
@Alpaq92
Alpaq92 deleted the security-hardening-and-fixes branch July 6, 2026 20:09
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