mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-05-15 17:03:20 +00:00
fix(security): centralize safe frontmatter parsing
Move frontmatter parsing into server/shared/frontmatter.ts so every backend caller uses the same gray-matter configuration instead of importing gray-matter directly. The goal is to keep executable JS and JSON frontmatter engines disabled for all markdown discovered from the filesystem, not only command routes. Provider skills and shared skill metadata now go through parseFrontMatter too. That closes the gap where plugin or provider markdown could regain default gray-matter behavior simply because it lived outside the original command path. Classify the new parser in backend boundaries so modules can depend on the safe shared API without reaching into legacy utility paths.
This commit is contained in:
18
server/shared/frontmatter.ts
Normal file
18
server/shared/frontmatter.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import matter from 'gray-matter';
|
||||
|
||||
const disabledFrontmatterEngine = () => ({});
|
||||
|
||||
const frontmatterOptions = {
|
||||
language: 'yaml',
|
||||
// Disable JS/JSON frontmatter parsing to avoid executable project content.
|
||||
// Mirrors Gatsby's mitigation for gray-matter.
|
||||
engines: {
|
||||
js: disabledFrontmatterEngine,
|
||||
javascript: disabledFrontmatterEngine,
|
||||
json: disabledFrontmatterEngine,
|
||||
},
|
||||
};
|
||||
|
||||
export function parseFrontMatter(content: string) {
|
||||
return matter(content, frontmatterOptions);
|
||||
}
|
||||
Reference in New Issue
Block a user