Skip to content

fix: nightly hardening - yaml unsafe key guard#9

Open
mouse-value-add wants to merge 1 commit intomainfrom
chore/nightly-hardening-20260418-yaml-key-guard
Open

fix: nightly hardening - yaml unsafe key guard#9
mouse-value-add wants to merge 1 commit intomainfrom
chore/nightly-hardening-20260418-yaml-key-guard

Conversation

@mouse-value-add
Copy link
Copy Markdown
Collaborator

@mouse-value-add mouse-value-add commented Apr 18, 2026

problem

The YAML frontmatter parser accepted reserved JavaScript object keys like __proto__, constructor, and prototype. In JavaScript, writing these keys can mutate object prototypes or introduce confusing object behavior, which weakens parser safety when untrusted profile content is loaded.

approach

  • Added a guard in the YAML parser to reject unsafe object keys (__proto__, constructor, prototype) at parse time.
  • Applied the guard to both top-level YAML key parsing and inline object parsing ({key: value}).
  • Emit parser errors for blocked keys while continuing to parse safe fields.
  • Added focused unit tests to verify unsafe keys are blocked and safe fields still parse.

verification

  • Ran targeted tests: npm test -- --run test/parser/yaml.test.ts
  • Ran full suite: npm test
  • Result: 17 test files, 144 tests passed.

risks

  • Profiles that previously relied on these reserved keys will now receive parse errors and those fields will be ignored.
  • Error count can increase for malformed/untrusted inputs (intended behavior).

rollback plan

  • Revert commit 4a11163 to restore prior parser behavior.
  • If partial rollback is needed, remove only the unsafe-key guard checks in src/parser/yaml.ts and corresponding tests in test/parser/yaml.test.ts.

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.

1 participant