Repository navigation
Description
Twelve open code-scanning alerts, all gosec G115 (integer overflow conversion). They have accumulated because #415 closed with the conclusion that "gosec findings do not block a merge, and the job that runs gosec cannot fail" — so nothing has been watching them.
Reproduce:
gh api repos/scttfrdmn/objectfs/code-scanning/alerts --paginate \
--jq '.[] | select(.state=="open") | "\(.number)\t\(.most_recent_instance.location.path):\(.most_recent_instance.location.start_line)\t\(.most_recent_instance.message.text)"' | sort -t$'\t' -k2They are not one finding twelve times
I read all twelve. Three groups, and the first two are the reason this is not a blanket-suppress ticket.
1. Untrusted input — the one that actually matters
internal/archive/index.go:97
Mode: uint32(hdr.Mode),hdr.Mode is an int64 parsed from a tar header in an archive we did not write. The tar mode field is 12 octal bytes, so a crafted archive can carry a value that does not fit in uint32, or a negative one. Truncating it silently yields a different mode than the archive states, and this feeds ArchiveEntry.Mode — a permissions statement presented through the filesystem. Given this project’s stated priority order, a silently-wrong mode from attacker-controlled bytes is the defect here, not the conversion warning.
Wanted: an explicit range check, and a decision recorded for what an out-of-range mode means — reject the entry, or clamp and say so.
2. Two that are wrong for reasons gosec did not flag
internal/cache/predictive.go:768
return "feature_" + string(rune(index))string(rune(n)) builds the Unicode codepoint n, not its decimal text. For index == 5 this returns "feature_\x05" — a control character — where "feature_5" was plainly intended. strconv.Itoa is the fix. The overflow is the least of it; the function returns garbage today.
pkg/recovery/connection.go:578
index := cp.nextIndex.Add(1) % uint32(len(cp.managers))Overflow needs more than 4 billion managers, so that part is unreachable. len(cp.managers) == 0 panics on divide-by-zero, which is reachable, and gosec says nothing about it. An empty pool should return an error.
3. Bounded in practice; make the bound explicit or document the suppression
| location | conversion | note |
|---|---|---|
internal/storage/s3/multipart_upload.go:101 |
int → int32 part number |
S3 caps parts at 10,000 |
internal/storage/s3/multipart_upload.go:161 |
int → int32 |
same |
internal/storage/s3/backend.go:1798 |
int → int32 |
|
internal/health/remediation.go:413 (×2) |
uint64 → int64 HeapAlloc |
log line only; needs 2^63 bytes of heap |
internal/difftest/program.go:189 |
int → byte |
deliberate truncation in test-data generation |
sdks/c/main.go:304, :416 |
int → uint64 |
cgo boundary |
sdks/c/main.go:464 |
uint64 → int32 |
cgo boundary |
For these, either an explicit bound or a //nolint:gosec with the reason that makes it safe — the bound is the documentation. Note that a //nolint will not clear the alert: standalone gosec does not honour it, which is the disagreement #415 recorded.
The meta-problem
Twelve alerts reaching this state is the real finding. Whatever is decided per-site, decide also how a new G115 becomes visible — otherwise this ticket regenerates. This is why the issue sits in the same milestone as #508 and #512, which are the other two ways a red signal currently fails to stop anything.
Activity
fix(security): empty the G115 baseline the #nosec directives emptied (#…