[PR #4981] [MERGED] fix: close actionable code scanning findings #6566

Closed
opened 2026-10-23 04:11:39 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4981
Author: @SpicyMarinara
Created: 8/13/2026
Status: ✅ Merged
Merged: 8/13/2026
Merged by: @SpicyMarinara

Base: staging ← Head: agent/code-scanning-cleanup


📝 Commits (7)

  • e5068a3 fix: harden code scanning edge cases
  • 05e4610 fix: linearize untrusted content parsing
  • bea5c17 fix: handle malformed wiki closing tags
  • 4006e00 fix: decode Janny metadata once
  • ee15088 fix: preserve legacy parser behavior
  • 7701658 Merge branch 'staging' into agent/code-scanning-cleanup
  • c22ae2d fix: preserve malformed parser boundaries

📊 Changes

34 files changed (+1215 additions, -202 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 package.json (+3 -1)
📝 packages/client/src/components/agents/AgentEditor.tsx (+6 -1)
📝 packages/client/src/components/chat/AgentAddSetupFields.tsx (+5 -1)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+5 -1)
📝 packages/client/src/lib/card-asset-links.ts (+36 -4)
📝 packages/server/src/routes/backgrounds.routes.ts (+16 -3)
📝 packages/server/src/routes/bot-browser-chartavern.routes.ts (+7 -1)
📝 packages/server/src/routes/bot-browser-janny.routes.ts (+63 -14)
📝 packages/server/src/routes/bot-browser.routes.ts (+7 -1)
📝 packages/server/src/routes/characters.routes.ts (+12 -8)
📝 packages/server/src/routes/generate/agent-write-approval.ts (+49 -9)
📝 packages/server/src/routes/generate/generate-route-utils.ts (+32 -8)
📝 packages/server/src/routes/sprites.routes.ts (+8 -6)
📝 packages/server/src/services/conversation/character-commands.ts (+1 -1)
📝 packages/server/src/services/conversation/impersonate-prompt.ts (+9 -4)
📝 packages/server/src/services/game/segment-edits.ts (+200 -69)
📝 packages/server/src/services/generation/prompt-message-scope.ts (+47 -13)
📝 packages/server/src/services/import/import-timestamps.ts (+3 -2)
📝 packages/server/src/services/import/st-prompt.importer.ts (+48 -5)

...and 14 more files

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.

Linked issue

Maintainer-directed cleanup of the repository's open GitHub code-scanning findings; no separate issue requested.

Why this change

GitHub CodeQL currently mixes genuine parser, path, metadata, and outbound-fetch weaknesses with stale and framework-modeling false positives. The real findings should be fixed before release without disabling imports, extensions, local scripts, character cards, or other local-first capabilities.

What changed

  • Reject traversal-shaped character IDs before recursive gallery cleanup.
  • Use null-prototype background metadata and correct strict numeric parsing.
  • Replace polynomial parsing expressions in imported, model-authored, and chat text with deterministic scanners while preserving legacy formats.
  • Harden fixed-host character-card and Janny page downloads with validated redirects, response caps, content checks, and PNG signature verification.
  • Keep Fandom parsing and hostname classification exact.
  • Add focused behavioral and large-input regressions and register them in the aggregate suite.

The remaining CodeQL findings were separately audited. Framework-modeling false positives, intentional privileged local-file utilities, stale historical instances, and the explicit local-first saved-admin-secret tradeoff will be closed with documented dispositions after this patch lands.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Manually verify one Chub/CharacterTavern/Janny card download and ordinary character deletion before release.
  • Automated: pnpm check; pnpm version:check; pnpm regression:code-scanning-security; full prompt regressions; request-security regressions; open-issues, Bot Browser, Janny import, and Professor Mari wiki regressions; server/client/shared lint; production builds; git diff --check.
  • Adversarial large-input benchmarks cover malformed GM tags, imported prompt wrappers, card syntax, speaker tags, timestamps, macros, and Janny Astro markup.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

No UI behavior or visual styling changes.

Summary by CodeRabbit

  • Bug Fixes

    • Hardened parsing and sanitization for imported, generated, and model-authored content, including malformed, nested, oversized, and Unicode inputs.
    • Improved path validation and protected character deletion and asset downloads from unsafe paths, oversized responses, and invalid content.
    • Preserved supported import formats while improving timestamp, variable, metadata, prompt, and markup handling.
    • Corrected background metadata validation and protection against reserved-key manipulation.
  • Tests

    • Added comprehensive security regression coverage for path handling, content parsing, prompt parsing, metadata, and wiki processing.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/4981 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 8/13/2026 **Status:** ✅ Merged **Merged:** 8/13/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `agent/code-scanning-cleanup` --- ### 📝 Commits (7) - [`e5068a3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e5068a376ce2725f81a2beed9884b74815af9e30) fix: harden code scanning edge cases - [`05e4610`](https://github.com/Pasta-Devs/Marinara-Engine/commit/05e4610bccb560cb731fd1832f0a6f76ecd9ce4e) fix: linearize untrusted content parsing - [`bea5c17`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bea5c17fb9cbb3786573e397b067a5f5d1415b0b) fix: handle malformed wiki closing tags - [`4006e00`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4006e00deb3e13d864d22087838c7532965b69ef) fix: decode Janny metadata once - [`ee15088`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ee150886e33400690bf116d91ae3cef7577b6441) fix: preserve legacy parser behavior - [`7701658`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7701658b62a436f92c6eea5138fb36096ec987e9) Merge branch 'staging' into agent/code-scanning-cleanup - [`c22ae2d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c22ae2de3012a1454a6dcfc9845523e35926dde2) fix: preserve malformed parser boundaries ### 📊 Changes **34 files changed** (+1215 additions, -202 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `package.json` (+3 -1) 📝 `packages/client/src/components/agents/AgentEditor.tsx` (+6 -1) 📝 `packages/client/src/components/chat/AgentAddSetupFields.tsx` (+5 -1) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+5 -1) 📝 `packages/client/src/lib/card-asset-links.ts` (+36 -4) 📝 `packages/server/src/routes/backgrounds.routes.ts` (+16 -3) 📝 `packages/server/src/routes/bot-browser-chartavern.routes.ts` (+7 -1) 📝 `packages/server/src/routes/bot-browser-janny.routes.ts` (+63 -14) 📝 `packages/server/src/routes/bot-browser.routes.ts` (+7 -1) 📝 `packages/server/src/routes/characters.routes.ts` (+12 -8) 📝 `packages/server/src/routes/generate/agent-write-approval.ts` (+49 -9) 📝 `packages/server/src/routes/generate/generate-route-utils.ts` (+32 -8) 📝 `packages/server/src/routes/sprites.routes.ts` (+8 -6) 📝 `packages/server/src/services/conversation/character-commands.ts` (+1 -1) 📝 `packages/server/src/services/conversation/impersonate-prompt.ts` (+9 -4) 📝 `packages/server/src/services/game/segment-edits.ts` (+200 -69) 📝 `packages/server/src/services/generation/prompt-message-scope.ts` (+47 -13) 📝 `packages/server/src/services/import/import-timestamps.ts` (+3 -2) 📝 `packages/server/src/services/import/st-prompt.importer.ts` (+48 -5) _...and 14 more files_ </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. ## Linked issue Maintainer-directed cleanup of the repository's open GitHub code-scanning findings; no separate issue requested. ## Why this change GitHub CodeQL currently mixes genuine parser, path, metadata, and outbound-fetch weaknesses with stale and framework-modeling false positives. The real findings should be fixed before release without disabling imports, extensions, local scripts, character cards, or other local-first capabilities. ## What changed - Reject traversal-shaped character IDs before recursive gallery cleanup. - Use null-prototype background metadata and correct strict numeric parsing. - Replace polynomial parsing expressions in imported, model-authored, and chat text with deterministic scanners while preserving legacy formats. - Harden fixed-host character-card and Janny page downloads with validated redirects, response caps, content checks, and PNG signature verification. - Keep Fandom parsing and hostname classification exact. - Add focused behavioral and large-input regressions and register them in the aggregate suite. The remaining CodeQL findings were separately audited. Framework-modeling false positives, intentional privileged local-file utilities, stale historical instances, and the explicit local-first saved-admin-secret tradeoff will be closed with documented dispositions after this patch lands. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Manually verify one Chub/CharacterTavern/Janny card download and ordinary character deletion before release. - Automated: `pnpm check`; `pnpm version:check`; `pnpm regression:code-scanning-security`; full prompt regressions; request-security regressions; open-issues, Bot Browser, Janny import, and Professor Mari wiki regressions; server/client/shared lint; production builds; `git diff --check`. - Adversarial large-input benchmarks cover malformed GM tags, imported prompt wrappers, card syntax, speaker tags, timestamps, macros, and Janny Astro markup. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) No UI behavior or visual styling changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Hardened parsing and sanitization for imported, generated, and model-authored content, including malformed, nested, oversized, and Unicode inputs. - Improved path validation and protected character deletion and asset downloads from unsafe paths, oversized responses, and invalid content. - Preserved supported import formats while improving timestamp, variable, metadata, prompt, and markup handling. - Corrected background metadata validation and protection against reserved-key manipulation. - **Tests** - Added comprehensive security regression coverage for path handling, content parsing, prompt parsing, metadata, and wiki processing. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:11:39 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#6566
No description provided.