Skip to content

Commit 8bb16cc

Browse files
[security-fix] Security Fix: Allocation Size Overflow in Domain List Merging (Alert #6) (#1528)
1 parent db5f641 commit 8bb16cc

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

.changeset/patch-fix-allocation-overflow-mcp-domain-merging.md

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/parser/mcp.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ func EnsureLocalhostDomains(domains []string) []string {
3232
}
3333
}
3434

35-
result := make([]string, 0, len(domains)+4)
35+
// CWE-190: Allocation Size Overflow Prevention
36+
// Instead of pre-calculating capacity (len(domains)+4), which could overflow
37+
// if domains is extremely large, we let Go's append handle capacity growth
38+
// automatically. This is safe and efficient for domain arrays which are
39+
// typically small in practice.
40+
var result []string
3641

3742
// Always add localhost domains first (with and without port specifications)
3843
if !hasLocalhost {

0 commit comments

Comments
 (0)