fix: address PR #63 review findings
1. Refactor err2 to use scoped loadErr variable (MINOR - sonnet-review-bot) The else-if branches are mutually exclusive, so the error variable should be scoped inside the block, not declared outside with err2. 2. Sanitize DisplayName before embedding in Markdown (MINOR - security-review-bot) Remote persona metadata is untrusted. Added sanitizeMarkdownText() to escape Markdown special characters and strip control characters. Applied to both the header title and the footer attribution. 3. Document YAML DoS mitigations (MINOR - security-review-bot) Added comprehensive comment in remote_persona.go explaining existing defenses: file size limit, file count cap, depth limit, node count cap, and alias cycle detection. These collectively mitigate billion-laughs and stack exhaustion attacks.
This commit is contained in:
@@ -89,6 +89,13 @@ func LoadRemotePersonasFromPath(ctx context.Context, fetcher PersonaFetcher, own
|
||||
continue
|
||||
}
|
||||
|
||||
// YAML parsing uses parsePersona which has defenses against YAML DoS attacks:
|
||||
// - MaxPersonaFileSize (above) caps raw input size before any parsing
|
||||
// - maxPersonaFiles (above) limits the number of files processed per repo
|
||||
// - unmarshalYAMLWithDepthLimit enforces MaxYAMLDepth to prevent stack exhaustion
|
||||
// - checkYAMLDepth tracks node counts (MaxYAMLNodes) against "billion laughs" expansion
|
||||
// - Alias cycles are detected and capped by seen-node tracking
|
||||
// See persona.go for the implementation details.
|
||||
persona, err := parsePersona([]byte(content), entry.Path)
|
||||
if err != nil {
|
||||
slog.Warn("could not parse remote persona file", "file", entry.Path, "error", err)
|
||||
|
||||
Reference in New Issue
Block a user