mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 21:24:31 +00:00
fix(security): use YAML core schema to prevent type coercion (#20857)
YAML 1.1 default schema silently coerces values like "on" to true and "off" to false, which can cause unexpected behavior in frontmatter parsing. Explicitly set schema: "core" to use YAML 1.2 rules that only recognize true/false/null literals.
This commit is contained in:
@@ -34,7 +34,7 @@ function coerceFrontmatterValue(value: unknown): string | undefined {
|
|||||||
|
|
||||||
function parseYamlFrontmatter(block: string): ParsedFrontmatter | null {
|
function parseYamlFrontmatter(block: string): ParsedFrontmatter | null {
|
||||||
try {
|
try {
|
||||||
const parsed = YAML.parse(block) as unknown;
|
const parsed = YAML.parse(block, { schema: "core" }) as unknown;
|
||||||
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user