Skip to content

Webhook signature verification panics in TinyGo modules using crypto under //go:export #346

Open

Description

@jeroenrinzema

Provider modules export their functions with //go:export and are built with tinygo build -buildmode c-shared. TinyGo runs those exports without a current goroutine. In Go 1.25's crypto/internal/fips140, every SHA-256 or HMAC Sum calls RecordApproved(), and TinyGo implements that as task.Current().FipsIndicator, which dereferences nil there.

The result is that any module verifying a webhook signature with crypto/sha256 or crypto/hmac traps. For example, Mailgun with a webhook signing key configured, called through the host registry:

mailgun webhook with signing key: wasm error: unreachable
wasm stack trace:
	main.runtime.runtimePanicAt(i32,i32)
	main.runtime.nilPanic()
	main.(*crypto/internal/fips140/hmac.HMAC).Sum(i32,i32,i32,i32)
	main.provider_webhook() i32

TinyGo's own source shows the cause (src/runtime/scheduler.go):

//go:linkname fips_getIndicator crypto/internal/fips140.getIndicator
func fips_getIndicator() uint8 {
	return task.Current().FipsIndicator
}

A minimal reactor reproduces it with TinyGo 0.40.1 and both Go 1.24.11 and 1.25.5: sha256.Sum256, sha256.New().Sum and hmac.New(sha256.New, …).Sum all trap under //go:export and return correct digests under //go:wasmexport.

Likely affected: every module that hashes inside an export. That includes Mailgun (signing key), Resend (svix verification) and probably SendGrid's ECDSA check. None of these are checked yet except Mailgun.

Fix: switch the exports to //go:wasmexport, as the AhaSend provider does in #345. A module that imports the Extism PDK then can't be linked by the standard toolchain's test runner, so #345 moves the exports into a //go:build tinygo file.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions