fix(agent): prevent panic in parseImageDetails for digest-pinned images#1723
Merged
Conversation
parseImageDetails computed the colon (tag) position on the full image string *before* stripping the @digest suffix. For digest-pinned, tagless images such as quay.io/openshift-release-dev/ocp-release@sha256:... — ubiquitous on OpenShift — the colon inside "sha256:" produced a colonLocation past the truncated string length, causing a "slice bounds out of range" panic at `name = image[slashLocation+1 : colonLocation]`. This panic occurred in the out_oms flush path via the KubernetesMetadata enrichment (processIncludes -> parseImageDetails), core-dumping fluent-bit and crash-looping the ama-logs daemonset on affected clusters. Fix: move the @digest truncation to the top of the function so the slash and colon positions are computed on the already-cleaned string and can never exceed its length. Add a table-driven TestParseImageDetails covering all image reference formats (bare name, name+tag, name+digest, namespace/name, host/path, multi-segment paths, tag+digest, registry:port quirks, and empty string) plus TestProcessIncludesDigestPinnedImage exercising the end-to-end metadata path that previously panicked. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
zanejohnson-azure
approved these changes
Jun 29, 2026
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
parseImageDetailscould panic withslice bounds out of rangewhen processing digest-pinned, tagless container images (e.g.quay.io/openshift-release-dev/ocp-release@sha256:...), which are ubiquitous on OpenShift. The panic crashed fluent-bit'sout_omsplugin during flush and crash-looped theama-logsdaemonset on affected clusters (observed restartCount in the hundreds, with intermittent/zeroContainerLogV2ingestion).Root cause
colonLocation(the tag delimiter) was computed on the full image string, before the@<digest>suffix was stripped:For
quay.io/openshift-release-dev/ocp-release@sha256:ed3b...:colonLocation= 48 (the:insha256:)@truncation,len(image)= 41name = image[8:48]→slice bounds out of range [:48] with length 41The existing
if colonLocation < len(image)guard only protected thetagslice; the panic happened one block earlier on the unguardednameslice. This path is reached through KubernetesMetadata enrichment:FLBPluginFlush→PostDataHelper→processIncludes→parseImageDetails.Fix
Move the
@<digest>truncation to the top of the function soslashLocationandcolonLocationare computed on the already-cleaned string and can never exceed its length. Behavior is unchanged for all previously-working formats.Tests
TestParseImageDetails— table-driven, 15 cases covering every reference form: bare name,name:tag,name@digest,namespace/name(+tag/+digest),host/path(+tag/+digest), multi-segment paths,taganddigest, the OpenShift digest-tagless case (the panic repro),registry:portquirks, and empty string.TestProcessIncludesDigestPinnedImage— exercises the end-to-end metadata path that previously panicked.go build ./...andgo test ./source/plugins/go/srcboth pass.Notes
The simplified parser still mis-splits a registry with an explicit
:port(e.g.myregistry.io:5000/team/app:1.0) — this is pre-existing, non-panicking behavior and is documented as a known limitation in the new tests.