fix(security): resolve open CodeQL code-scanning alerts#1016
Conversation
|
🤖 Claude Code Review Status: Complete Security Fixes Analysis: All 11 CodeQL alerts have been properly addressed. The fixes are correct, minimal, and well-documented: Integer Conversion Safety (alerts #90, #91, #117, #113)
Prototype Pollution (alerts #79, #81, #83)
Dead Code Removal (alerts #2, #4)
XSS Fix (alert #1)
Documentation-Only (alert #42)
No Issues Found The PR demonstrates careful security engineering. Fixes are minimal, behavior changes are limited to rejecting invalid input, and documentation is thorough. |
Address the open CodeQL code-scanning alerts: - httpimpl: bound-check int->uint32 conversions before casting in GetBlocks (offset) and GetNearestForkHeights (range) to prevent truncation/wrap-around (go/incorrect-integer-conversion, bsv-blockchain#90 bsv-blockchain#91 bsv-blockchain#117) - daemon: change formatBytes to take uint64, removing the unchecked int64(limit) narrowing of the cgroup memory limit (bsv-blockchain#113) - dashboard p2pStore: reject __proto__/constructor/prototype peer_id keys before any plain-object write to prevent prototype pollution from WebSocket data (bsv-blockchain#79 bsv-blockchain#81 bsv-blockchain#83) - dashboard urlUtils: remove the dead sanitizeUrl function entirely (no callers, no tests); its broken script-tag regex was the source of the alerts (js/bad-tag-filter, js/incomplete-multi-character-sanitization, bsv-blockchain#2 bsv-blockchain#4) - centrifuge client: use textContent instead of innerHTML in drawText to fix DOM XSS from server-controlled push data (bsv-blockchain#1) - grpc_helper: document that SecurityLevel 1 leaves the server cert unverified (MITM); behaviour unchanged, bsv-blockchain#42 is an intentional config-gated mode dismissed on GitHub
8e22229 to
e4cb84f
Compare
Benchmark Comparison ReportBaseline: Current: Summary
All benchmark results (sec/op)
Threshold: >10% with p < 0.05 | Generated: 2026-06-02 10:33 UTC |
|
ordishs
left a comment
There was a problem hiding this comment.
Clean, well-scoped security PR. Each CodeQL alert is fixed with a minimal, correct change and no collateral refactoring:
- GetBlocks/GetNearestForkHeights int→uint32 bound checks compose correctly with existing non-negative validation.
- formatBytes(uint64) removes all narrowing; upstream guards keep every cast safe.
- p2pStore proto/constructor/prototype denylist + hasOwnProperty guard; no false positives on base58 peer IDs.
- Dead sanitizeUrl removal and innerHTML→textContent are strictly correct.
- grpc_helper is doc-only; InsecureSkipVerify stays gated behind opt-in SecurityLevel==1.
Verified go vet clean on daemon, services/asset/httpimpl, util. 32-bit compile caveat is moot (amd64/arm64 only) and was self-flagged. Approve.


What
Resolves the 11 open CodeQL code-scanning alerts.
services/asset/httpimpl/{GetBlocks,GetNearestForkHeights}.goint→uint32conversion before casting (reject out-of-rangeoffset/rangewith HTTP 400). Prevents silent truncation/wrap-around.daemon/daemon_memlimit.goformatBytesnow takesuint64, removing the uncheckedint64(limit)narrowing of the cgroup memory limit. Log output unchanged.ui/dashboard/src/internal/stores/p2pStore.ts__proto__/constructor/prototypeaspeer_idkeys before any plain-object write; guard thefor…inwithhasOwnProperty. Prevents prototype pollution from WebSocket data.ui/dashboard/src/internal/utils/urlUtils.tssanitizeUrlfunction entirely (no callers, no tests). Its broken script-tag regex was the source of both alerts;validateUrl(the function actually in use) is untouched.services/asset/centrifuge_impl/client/index.htmlinnerHTML→textContentindrawText— real DOM XSS from server-controlled push data.white-space: prepreserves rendering.util/grpc_helper.goInsecureSkipVerifyis reached only via the explicit, operator-opted-inSecurityLevel==1(default is0). Added godoc/comment warning that level 1 leaves the server certificate unverified (MITM). Alert dismissed on GitHub as intentional/config-gated.Verification
go build+go veton affected packages (daemon,services/asset/httpimpl,util) — cleango test(targeted:TestFormatBytes,TestParseCgroupMemoryValue,GetBlocks,LimitOffset,NearestForkHeights) — passsvelte-check— 0 errors (798 files; 14 pre-existing warnings, none in changed files)gofmt -l— cleanNotes
range/offsetnow return HTTP 400 instead of silently wrapping; WS messages with a__proto__-stylepeer_idare dropped. No legitimate request is affected.x > math.MaxUint32guards won't compile on 32-bit (untyped-const overflow). Moot — Teranode builds only amd64/arm64 and the asset pkg requires 64-bit cgo.