fix/audit2 019 skill frontmatter injection#1337
Open
tsitu0 wants to merge 2 commits into
Open
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
Purpose / Description
Fix AUDIT2-019 (related: OBSV-SEC-042): skill slash-command frontmatter could be injected through unescaped generated fields and insufficient validation of verbatim
SKILL.mdcontent.This is intentionally broader than a one-line escaping fix. Slash commands can enter Observal through multiple paths: API requests, registry-direct
SKILL.mdcontent, git-fetchedSKILL.md, draft edits, component-version publishing, agent composition, install/config generation, and self-learn generated skills. The fix hardens both sides of the boundary:SKILL.mdfrontmatter before storing or emitting itApproach
Centralized slash-command normalization (
schemas/skill_commands.py):^[a-z0-9][a-z0-9_-]{0,63}$/is accepted and normalized away for storageNonefor update/clear semanticsStrict validation for stored/verbatim
SKILL.mdfrontmatter:command:values are rejectedslash_commandand frontmattercommand:must agree when both are presentskill_md_contentis preserved unchangedApplied validation at the relevant ingress/egress points:
SKILL.mdvalidationReplaced generated fallback frontmatter string interpolation with
yaml.safe_dump()in:services/skill_config_generator.pyservices/config/skill_builder.pyservices/insights/self_learn.pyAlso fixed empty
slash_commandupdate behavior so an explicit empty string clears the stored command.Note: pre-commit hooks added SPDX headers to touched files and normalized
CHANGELOG.mdEOF in a separatechore:commit.How Has This Been Tested?
Focused tests:
Result:
Lint:
Result:
Whitespace:
Result: passed.
Route-level regression coverage was also added in
tests/test_registry_types.py. In this local environment, that file does not collect becausejwtis missing:Learning (optional)
The risky pattern was not only string interpolation in generated YAML. The larger issue was that verbatim
SKILL.mdcontent can cross several boundaries before install. For that reason, this patch validates both generated and verbatim frontmatter paths.For generated fallback files,
yaml.safe_dump()emits user-controlled fields as YAML data rather than YAML syntax.Checklist
fix(security): validate skill slash commands, 41 chars)