Skip to content

Commit a59d76c

Browse files
Add traversal limit to TransformExcC14n to prevent pathological XML inputs
transformExcC14n recursed through child elements without checking the NSContext traversal limit, unlike other recursive functions (NSTraverse, etc.). Deeply nested XML documents could cause unbounded recursion. Add CheckLimit() call at the top of the recursive function.
1 parent 48a1e2f commit a59d76c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

internal/xmldsig/etree_canonicalize.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ func TransformExcC14n(el *etree.Element, inclusiveNamespacesPrefixList string, c
2626
}
2727

2828
func transformExcC14n(ctx, declared NSContext, el *etree.Element, inclusiveNamespaces map[string]struct{}, comments bool) error {
29+
if err := ctx.CheckLimit(); err != nil {
30+
return err
31+
}
32+
2933
scope, err := ctx.SubContext(el)
3034
if err != nil {
3135
return err

0 commit comments

Comments
 (0)