fix: escape single quotes and backticks in vault secret values#407
Merged
fix: escape single quotes and backticks in vault secret values#407
Conversation
The vault.get() regex accepts single quotes, double quotes, and backticks as argument delimiters, but the escaping logic only handled double quotes (plus backslashes and whitespace). Add escaping for single quotes and backticks as defense-in-depth against future quoting changes. Co-Authored-By: Magistr <2269529+umag@users.noreply.github.com>
There was a problem hiding this comment.
Review Summary
This PR adds defense-in-depth escaping for single quotes and backticks in vault secret values. The changes are well-crafted and focused.
Blocking Issues
None - This PR is ready to merge.
Review Details
Code Quality & TypeScript Strict Mode ✅
- No
anytypes introduced - Simple, correct regex replacements
- Proper escaping order (backslashes first, then quotes/special chars)
CLAUDE.md Compliance ✅
- Named exports used throughout
- AGPLv3 copyright headers present
- CI confirms:
deno check,deno lint,deno fmtall pass
Domain-Driven Design ✅
ModelResolveris appropriately placed insrc/domain/expressions/- Escaping logic is a valid domain service responsibility
- No DDD violations
Test Coverage ✅
- Two new dedicated test cases for single quotes and backticks
- Three existing tests updated to reflect new escaping behavior
- Tests use
@std/assertas required - All 24 test steps pass per CI
Security ✅
- This PR improves security with defense-in-depth escaping
- Even though double-quote wrapping already prevents breakout today, escaping these characters ensures safety if the quoting strategy changes
- Confirmed cel-js v7.3.1 supports both
\'and\`escape sequences
Suggestions (non-blocking)
None - this is a clean, focused fix.
🤖 Reviewed by Claude Code
This was referenced Feb 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #394
Summary
') and backtick (`) escaping to the vault secret value escape chain inmodel_resolver.tsProblem
The
vault.get()regex accepts three quote styles as argument delimiters (',",`), but the escaping logic only handled double quotes, backslashes, and whitespace characters (\n,\r,\t). While the current double-quote wrapping ("${escapedValue}") means unescaped single quotes and backticks can't break out of the string today, this is an incomplete defense-in-depth.Plan vs Implementation
The plan called for:
.replace(/'/g, "\\'")and.replace(//g, "\")after the double-quote escape — implemented exactly as plannedOne aspect not anticipated in the plan: three existing tests (
$'pattern,$`pattern, and multi-dollar pattern) contained single quotes or backticks in their secret values and needed their expected outputs updated to reflect the new escaping. This was a straightforward consequence of the change.Changes
src/domain/expressions/model_resolver.tsAdded two
.replace()calls to the escape chain:src/domain/vaults/vault_expression_test.tsp@ss'w0rd→"p@ss\\'w0rd"value`with`backticks→"value\`with\`backticks"Verification
deno check— passesdeno lint— passesdeno fmt— passesdeno run test src/domain/vaults/vault_expression_test.ts— all 24 steps passNote on user impact
The practical user impact today is none — the double-quote wrapping already prevents these characters from causing issues. This is a defense-in-depth fix that ensures safety if the quoting strategy is ever changed. Confirmed that cel-js v7.3.1 supports both
\'and\`as valid escape sequences.🤖 Generated with Claude Code