-
Notifications
You must be signed in to change notification settings - Fork 91
XML validator hangs on recursive entity expansion #503
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershas-prThis issue has an associated PRThis issue has an associated PRhelp wantedExtra attention is neededExtra attention is neededvalidator-coreIssues that relate to the core validator functionalityIssues that relate to the core validator functionality
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershas-prThis issue has an associated PRThis issue has an associated PRhelp wantedExtra attention is neededExtra attention is neededvalidator-coreIssues that relate to the core validator functionalityIssues that relate to the core validator functionality
Type
Fields
Give feedbackNo fields configured for issues without a type.
The XML validator hangs indefinitely when parsing a file with recursive DTD entity definitions. The helium parser expands entities without depth or size limits, and we pass
context.Background()with no timeout.Any XML file with entities that reference other entities will cause unbounded expansion. The process pins a CPU core and never returns.
Cause
helium.NewParser().ValidateDTD(true).Parse(ctx, b)has no expansion limit. Since we passcontext.Background(), there's nothing to abort the parse.Suggested fix
Wrap the parse in a context with a timeout:
This preserves DTD validation for normal files while preventing the hang. If the timeout fires, return a validation error indicating the file took too long to parse.