Skip to content

fix(sink): always update requestActiveStartBlock on session init#792

Open
maoueh wants to merge 2 commits into
developfrom
bug/sinker-session-init-handler-break
Open

fix(sink): always update requestActiveStartBlock on session init#792
maoueh wants to merge 2 commits into
developfrom
bug/sinker-session-init-handler-break

Conversation

@maoueh
Copy link
Copy Markdown
Contributor

@maoueh maoueh commented May 28, 2026

Summary

Fixes a latent bug in (*Sinker).doRequest's Response_Session handling. When the registered handler implemented SinkerSessionInitHandler, the case body did a bare break right after invoking HandleSessionInit, which skipped the sinker-internal bookkeeping that follows — most importantly s.requestActiveStartBlock = session.ResolvedStartBlock.

That field is consumed in the Response_ModulesProgress case to identify the contiguous completed range covering the user's resolved start block. With requestActiveStartBlock left at zero, the predicate 0 <= r.StartBlock && r.EndBlock >= 0 is trivially true, causing ProgressMessageLastContiguousBlock to be overwritten by every completed range of the last (mapper) stage in production mode instead of only the contiguous one. Impact is metric-only (no data correctness impact) and latent today since no SF repo currently implements SinkerSessionInitHandler.

Changes:

  • Extract the Response_Session case body into (*Sinker).handleSessionInit. The custom SinkerSessionInitHandler.HandleSessionInit callback (when implemented) now runs as an interceptor: the default "session initialized with remote endpoint" log line and the requestActiveStartBlock assignment always run afterwards, regardless of whether a custom handler is installed.
  • Document the SinkerSessionInitHandler interface (sink/types.go) to make explicit that it behaves as an interceptor and does not short-circuit the sinker's default session handling.
  • Add regression tests in sink/sinker_test.go.
  • Add a changelog entry under ## Unreleased.

Test plan

  • go test ./sink/... passes
  • go vet ./sink/ clean
  • Confirm ProgressMessageLastContiguousBlock metric stays correct for a production-mode mapper sink that implements SinkerSessionInitHandler

maoueh added 2 commits May 28, 2026 09:58
The Response_Session case in (*Sinker).doRequest short-circuited with a
bare `break` when the handler implemented SinkerSessionInitHandler,
skipping the `s.requestActiveStartBlock = r.Session.ResolvedStartBlock`
assignment. That field is consumed by the Response_ModulesProgress case
to compute ProgressMessageLastContiguousBlock for production-mode mapper
stages, so a custom session-init handler silently left the metric wrong.

Remove the `break` entirely: the custom handler (when present) is still
invoked, but the default log line and the requestActiveStartBlock
assignment now run unconditionally. The case body is extracted into a
documented private method (*Sinker).handleSessionInit for testability.

# Conflicts:
#	docs/release-notes/change-log.md
Document on the SinkerSessionInitHandler interface that HandleSessionInit
behaves as an interceptor and does not short-circuit the Sinker's normal
session-init handling: the default "session initialized" log line and the
internal resolved-start-block bookkeeping still run after the callback.
@maoueh maoueh force-pushed the bug/sinker-session-init-handler-break branch from 1df8f5f to 49c9cc5 Compare May 28, 2026 13:58
@sduchesneau
Copy link
Copy Markdown
Contributor

🔍 Vulnerabilities of ghcr.io/streamingfast/substreams:c23cbb8

📦 Image Reference ghcr.io/streamingfast/substreams:c23cbb8
digestsha256:08b189fdea008f7530b53dc595c0484dd3e33f47fd7a81400af67e9c7f82871f
vulnerabilitiescritical: 8 high: 2 medium: 0 low: 0
platformlinux/amd64
size116 MB
packages353
📦 Base Image ubuntu:24.04
also known as
  • 84bda043709f9066841484e9b8e440aa0d6d04ab49d09e367ef0fb68ace864cf
  • latest
  • noble
  • noble-20260410
digestsha256:cdb5fd928fced577cfecf12c8966e830fcdf42ee481fb0b91904eeddc2fe5eff
vulnerabilitiescritical: 0 high: 0 medium: 22 low: 2
critical: 7 high: 2 medium: 0 low: 0 golang.org/x/crypto 0.50.0 (golang)

pkg:golang/golang.org/x/crypto@0.50.0

# ./Dockerfile (17:17)
COPY --from=build /app/substreams /app/substreams

critical : CVE--2026--46595

Affected range<0.52.0
Fixed version0.52.0
EPSS Score0.040%
EPSS Percentile12th percentile
Description

Previously, CVE-2024-45337 fixed an authorization bypass for misused ssh server configurations; if any other type of callback is passed other than public key, then the source-address validation would be skipped.

critical : CVE--2026--42508

Affected range<0.52.0
Fixed version0.52.0
EPSS Score0.030%
EPSS Percentile9th percentile
Description

Previously, a revoked 'SignatureKey' belonging to a CA was not correctly checked for revocation. Now, both the 'key' and 'key.SignatureKey' are checked for @Revoked.

critical : CVE--2026--39834

Affected range<0.52.0
Fixed version0.52.0
EPSS Score0.042%
EPSS Percentile13th percentile
Description

When writing data larger than 4GB in a single Write call on an SSH channel, an integer overflow in the internal payload size calculation caused the write loop to spin indefinitely, sending empty packets without making progress. The size comparison now uses int64 to prevent truncation.

critical : CVE--2026--39833

Affected range<0.52.0
Fixed version0.52.0
EPSS Score0.033%
EPSS Percentile10th percentile
Description

The in-memory keyring returned by NewKeyring() silently accepted keys with the ConfirmBeforeUse constraint but never enforced it. The key would sign without any confirmation prompt, with no indication to the caller that the constraint was not in effect. NewKeyring() now returns an error when unsupported constraints are requested.

critical : CVE--2026--39832

Affected range<0.52.0
Fixed version0.52.0
EPSS Score0.030%
EPSS Percentile9th percentile
Description

When adding a key to a remote agent constraint extensions such as restrict-destination-v00@openssh.com were not serialized in the request. Destination restrictions were silently stripped when forwarding keys, allowing unrestricted use of the key on the remote host. The client now serializes all constraint extensions. Additionally, the in-memory keyring returned by NewKeyring() now rejects keys with unsupported constraint extensions instead of silently ignoring them.

critical : CVE--2026--39831

Affected range<0.52.0
Fixed version0.52.0
EPSS Score0.022%
EPSS Percentile7th percentile
Description

The Verify() method for FIDO/U2F security key types (sk-ecdsa-sha2-nistp256@openssh.com, sk-ssh-ed25519@openssh.com) did not check the User Presence flag. Signatures generated without physical touch were accepted, allowing unattended use of a hardware security key. To restore the previous behavior, return a "no-touch-required" extension in Permissions.Extensions from PublicKeyCallback.

critical : CVE--2026--39830

Affected range<0.52.0
Fixed version0.52.0
EPSS Score0.042%
EPSS Percentile13th percentile
Description

A malicious SSH peer could send unsolicited global request responses to fill an internal buffer, blocking the connection's read loop. The blocked goroutine could not be released by calling Close(), resulting in a resource leak per connection. Unsolicited global responses are now discarded.

high : CVE--2026--46597

Affected range<0.52.0
Fixed version0.52.0
EPSS Score0.042%
EPSS Percentile13th percentile
Description

An incorrectly placed cast from bytes to int allowed for server-side panic in the AES-GCM packet decoder for well-crafted inputs.

high : CVE--2026--39829

Affected range<0.52.0
Fixed version0.52.0
EPSS Score0.074%
EPSS Percentile22nd percentile
Description

The RSA and DSA public key parsers did not enforce size limits on key parameters. A crafted public key with an excessively large modulus or DSA parameter could cause several minutes of CPU consumption during signature verification. This could be triggered by unauthenticated clients during public key authentication. RSA moduli are now limited to 8192 bits, and DSA parameters are validated per FIPS 186-2.

critical: 1 high: 0 medium: 0 low: 0 golang.org/x/net 0.53.0 (golang)

pkg:golang/golang.org/x/net@0.53.0

# ./Dockerfile (17:17)
COPY --from=build /app/substreams /app/substreams

critical : CVE--2026--39821

Affected range<0.55.0
Fixed version0.55.0
EPSS Score0.045%
EPSS Percentile14th percentile
Description

The ToASCII and ToUnicode functions incorrectly accept Punycode-encoded labels that decode to an ASCII-only label. For example, ToUnicode("xn--example-.com") incorrectly returns the name "example.com" rather than an error.

This behavior can lead to privilege escalation in programs using the idna package. For example, a program which performs privilege checks on the ASCII hostname may reject "example.com" but permit "xn--example-.com". If that program subsequently converts the ASCII hostname to Unicode, it will inadvertently permits access to the Unicode name "example.com".

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants