mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2530] [Issue]: Marinara lorebook importer writes entry role with no allowlist (ST sibling normalizes) #1257
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1257
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Romuromylus on GitHub (Jun 9, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2530
Originally assigned to: @Romuromylus on GitHub.
Summary
Severity: Low — correctness (missing input normalization). The Marinara lorebook importer writes an imported entry's
rolestraight to the DB with no allowlist, while the SillyTavern sibling importer normalizes the same field throughresolveRole(). A hand-crafted.marinara.jsonlorebook can persist an arbitrary string as an entry's prompt-injection role.Expected behavior
The imported lorebook
roleshould be clamped to thesystem | user | assistantunion, matching the ST importer and the manual entry-create routes.Actual behavior
packages/server/src/services/import/marinara.importer.ts:458:The storage layer inserts it raw (
lorebooks.storage.tscreateEntry:role: input.role ?? "system"), with no zod parse on the bulk-import path. By contrast, the ST importer normalizes viaresolveRole()(st-lorebook.importer.ts:223-231, applied at:391), and the manual entry-create routes runcreateLorebookEntrySchema.parse(), which clampsroletoz.enum(["system","user","assistant"])(lorebook.schema.ts:164). The import path is the one call site that skips this. The raw role propagates into a providerPromptMessagerole (prompt-injector.ts:117).Steps to reproduce
.marinara.jsonlorebook export so an entry'sroleis a non-enum string.Environment
staging @ a9fdae8)Logs, screenshots, or video
Static source audit, cited to file:line above.
Additional context
This is a normalization/data-integrity inconsistency, not a security exploit —
roleis prompt-injection metadata, not a dangerous sink, and an out-of-enum value is non-standard injection metadata rather than RCE/XSS/SSRF/data-loss. Hence Low.Fix: reuse the
resolveRole()pattern fromst-lorebook.importer.ts(or a shared helper) inimportLorebookso the imported role is clamped to the union, matching the ST importer.selectiveLogic/positiondeserve the same treatment if not already validated downstream.Regression notes: found via static audit;
main(65a0395,marinara.importer.ts:447) has the byte-identical unclamped assignment, so this is a long-standing shared bug, not amain→stagingregression.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked: