Skip to content

sdks/c: audit the G115 integer conversions that SARIF now drops — nothing else tracks them #200

Closed

Description

@scttfrdmn

.github/workflows/security.yml filters gosec results that carry no resolvable location before uploading SARIF, because GitHub's ingester rejects the whole submission if any single result lacks one — 3 bad entries were discarding the other 45.

The 3 dropped findings are all G115 integer conversions in sdks/c/main.go. They have no location because gosec analyses the cgo-generated intermediate and cannot map back to a real file, so there is nothing to point a reviewer at. Dropping them was right; inventing a line number would have been worse.

But that means nothing now tracks them. This issue is that tracker.

sdks/c/main.go is 454 lines with ~12 int-width conversions across the cgo boundary. The ones that matter are where a Go int/int64 becomes a C type of different width or signedness — a truncated length or a sign-flipped offset crossing into C is exactly the class that produces a wrong-sized read with no error, and this file is the SDK surface, so a caller in C sees the consequence and not the cause.

Do:

  • Audit each conversion by hand against the C signature it feeds. Note that pkg/types.Backend now defines size <= 0 semantics (v0.10.1), so some of these may have a defined answer they are not honouring.
  • Where a conversion can truncate, clamp or return an error — the C API should be able to report a bad length rather than perform a short one.
  • Consider running gosec directly against sdks/c with CGO_ENABLED=0 to see whether the findings resolve to real lines outside the cgo build; if they do, they can go back into SARIF and this issue closes into the normal flow.

Verification: a table test per conversion at boundary values, and — the load-bearing one — a C-side test that a length exceeding the C type's range is rejected rather than silently wrapped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: sdkeffort: smallpriority: mediumtype: security

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions