Skip to content

Harden workflows and server paths/output to resolve Code Scanning alerts #76–#100 - #3

Draft
kerrrang9214-tech with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-code-scanning-alerts
Draft

Harden workflows and server paths/output to resolve Code Scanning alerts #76–#100#3
kerrrang9214-tech with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-code-scanning-alerts

Conversation

Copilot AI commented Aug 26, 2026

Copy link
Copy Markdown

Make sure to read the contributing guidelines before submitting a PR

This updates CI workflow and server-side input/output handling to address the full set of code scanning findings (ggml-org#76–#100) with minimal, targeted changes. The fixes focus on permission scope, untrusted ref handling, traversal prevention, and output sanitization.

  • GitHub Actions hardening

    • Added explicit workflow permissions in build.yml (contents: read).
    • Removed user-controlled workflow_dispatch SHA from checkout ref selection in server workflows.
    • Standardized checkout to trusted refs:
      ref: ${{ github.event.pull_request.head.sha || github.sha }}
  • Static server security fixes (scripts/serve-static.js)

    • Enforced static-root containment using resolved paths before file access.
    • Return 403 Forbidden for traversal attempts.
    • Escaped directory listing data (reqUrl, filenames) before rendering HTML to prevent reflected XSS.
  • Client-side sanitization fix (tools/server/public_simplechat/simplechat.js)

    • Replaced single newline substitution with global replacement to avoid incomplete sanitization in error formatting:
      console.error(msg.replace(/\n/g, ":"));
  • Alert disposition

Copilot AI lite review requested due to automatic review settings August 26, 2026 00:28

Copilot AI 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.

Copilot wasn't able to review any files in this pull request.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: kerrrang9214-tech <242015866+kerrrang9214-tech@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 26, 2026 00:35
Copilot AI changed the title [WIP] Fix code scanning alerts #76 to #100 Harden workflows and server paths/output to resolve Code Scanning alerts #76–#100 Aug 26, 2026

Copilot AI 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.

🟡 Changes recommended

A few security/ops hardening details still need adjustment (CRLF log sanitization, consistent path passed to dir listing generation, and workflow permissions likely needed for caching).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 3
  • Review effort level: Lite

Comment thread scripts/serve-static.js
Comment on lines +84 to +86
const requestPath = decodeURIComponent(new URL(req.url, 'http://localhost').pathname);
const filePath = path.resolve(STATIC_DIR, `.${requestPath}`);
if (filePath !== STATIC_DIR && !filePath.startsWith(`${STATIC_DIR}${path.sep}`)) {
Comment on lines +50 to +52
permissions:
contents: read

this.handle_user_submit(this.curChatId, gMe.apiEP).catch((/** @type{Error} */reason)=>{
let msg = `ERRR:SimpleChat\nMCUI:HandleUserSubmit:${this.curChatId}\n${reason.name}:${reason.message}`;
console.error(msg.replace("\n", ":"));
console.error(msg.replace(/\n/g, ":"));
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.

3 participants