[sergo] Sergo Report: New-Feature Validation Gap + YAML Injection Revisit - 2026-03-16 #21291
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Sergo - Serena Go Expert. A newer discussion is available at Discussion #21454. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Executive Summary
Today's Sergo run targeted the freshly-merged commit
2181d15("Supportgithub-app:auth independencies:for cross-org APM packages"), auditing the entire new feature path from YAML parsing through code generation. The cached half revisited the YAML injection surface already explored in runs 21–22, confirming the newbuildAPMAppTokenMintStepandbuildGitHubAppTokenMintStepare safe from YAML injection (GitHub org/repo names are alphanumeric+hyphen only). The new exploration half traced every step of the cross-org APM auth flow and found two HIGH-severity issues that were introduced with this commit: a silent validation failure that will cause confusing runtime errors for users who misconfiguredependencies.github-app, and a missing token revocation step that leaves minted GitHub App tokens live for up to one hour after the activation job completes. A third MEDIUM finding covers a non-determinism inconsistency in the existingbuildGitHubAppTokenMintStep.Serena Tools Update
Tools Snapshot
Tool Capabilities Used Today
activate_projectsearch_for_patternlist_dirbash(grep + read)Strategy Selection
Cached Reuse Component (50%)
Previous Strategy Adapted:
yaml-step-generator-audit(runs 21–22, score 8/10)formatYAMLValuedoesn't escape embedded single quotes and thatcopilot_engine_execution.goinjectsCOPILOT_API_TARGETwithout quoting. The new commit adds two more functions that inject user-controlled strings into YAML (buildAPMAppTokenMintStepand its YAML output inapm_dependencies.go). Auditing these new paths with the same lens was a natural extension.runtime_step_generator.go/yaml.goto the brand-newapm_dependencies.goandsafe_outputs_app_config.gofunctions. Checkedapp.AppID,app.PrivateKey,app.Owner, andapp.Repositories[0]injection points.ownerandrepositoriesvalues follow GitHub naming restrictions (alphanumeric + hyphen only), so no YAML injection is possible in practice.New Exploration Component (50%)
Novel Approach: New-feature validation-gap audit of
github-app:independencies:search_for_pattern, bash (grep/read), line-by-line code tracingpkg/workflow/frontmatter_extraction_metadata.go,pkg/workflow/apm_dependencies.go,pkg/workflow/compiler_activation_job.goCombined Strategy Rationale
The cached component provided a precise audit lens (YAML injection in token-building functions), while the new component traced the entire feature lifecycle. Together they covered both the security surface of the YAML output and the correctness/security of the runtime token lifecycle.
Analysis Execution
Codebase Context
pkg/workflow/apm_dependencies.go,pkg/workflow/frontmatter_extraction_metadata.go,pkg/workflow/compiler_activation_job.go,pkg/workflow/safe_outputs_app_config.go2181d15— "Supportgithub-app:auth independencies:for cross-org APM packages"Findings Summary
Detailed Findings
Finding 1 — Silent drop of invalid
dependencies.github-appconfig (HIGH)File:
pkg/workflow/frontmatter_extraction_metadata.go:388–393When the user configures
dependencies.github-appbut omits a required field (app-idorprivate-key), the code silently setsgithubApp = niland logs only to the internal debug logger:The compiler then proceeds normally: it emits the "Using experimental feature: dependencies (APM)" warning (from
compiler.go:260), compiles successfully, and generates an APM pack step without theenv: GITHUB_TOKEN:override. The workflow deploys successfully but fails at runtime with a cryptic 404 / authentication error when APM tries to pull from the cross-org private package registry.Contrast with
checkout.github-app—checkout_manager.go:809-810returns a hard compiler error for the identical condition:This is a clear inconsistency. The
checkoutpath fails fast at compile time; thedependenciespath silently degrades to unauthenticated access.Impact: Users configuring cross-org APM auth get a compile-time success, a deployed workflow, and a confusing runtime failure — with no actionable clue that their
github-appconfig was ignored.Recommendation: Emit a user-visible compiler warning (or error, to match checkout behavior) from
extractAPMDependenciesFromFrontmatteror its caller incompiler_orchestrator_tools.go.Or, if a non-fatal path is preferred, bubble up a warning to
compiler_orchestrator_tools.gowherefmt.Fprintln(os.Stderr, console.FormatWarningMessage(...))+c.IncrementWarningCount()can be called.Finding 2 — APM GitHub App token never revoked after use (HIGH — Security)
Files:
pkg/workflow/apm_dependencies.go+pkg/workflow/compiler_activation_job.goThe new
buildAPMAppTokenMintStepmints a token with step IDapm-app-token:In
compiler_activation_job.go:414–424, this mint step is appended to the activation job and the APM pack step uses the token. But there is no corresponding revocation step after the pack step completes. The token remains valid for up to one hour.Every other GitHub App token mint in the codebase has a paired revocation step:
safe-outputs-app-tokencompiler_safe_outputs_job.go:303,notify_comment.go:357checkout-app-tokencheckout_manager.go:323mcp-github-app-tokenmcp_github_config.go:494activation-app-tokencompiler_activation_job.go:335apm-app-tokenbuildGitHubAppTokenInvalidationStepis hardcoded to referencesafe-outputs-app-tokenin itsif:condition andenv:block, so it cannot simply be reused as-is.Recommendation: Add a dedicated
buildAPMAppTokenInvalidationStepfunction (analogous tobuildGitHubAppTokenInvalidationStep) that referencesapmAppTokenStepID, and call it incompiler_activation_job.goafter the upload-artifact step:New function:
Validation: Add a test to
apm_dependencies_compilation_test.goasserting the invalidation step is present in the compiled output whenGitHubApp != nil.Finding 3 — buildGitHubAppTokenMintStep multi-repo list unsorted (MEDIUM)
File:
pkg/workflow/safe_outputs_app_config.go:158–163When
safe-outputs.github-app.repositoriescontains more than one entry,buildGitHubAppTokenMintStepiterates them in the order they appear in the frontmatter YAML:By contrast, the new
buildAPMAppTokenMintStep(apm_dependencies.go:54–60) correctly sorts before iterating:The inconsistency means that a user who reorders
safe-outputs.github-app.repositoriesin their workflow frontmatter without changing the set will produce a different compiled YAML and lock file, triggering unnecessary review diffs.Recommendation: Apply the same sort in
buildGitHubAppTokenMintStep:Estimated Effort: Small (3 lines, mirrors the APM implementation exactly).
Improvement Tasks Generated
Task 1: Emit user-visible error for invalid
dependencies.github-appconfigIssue Type: Validation Gap / API Consistency
Problem:
frontmatter_extraction_metadata.go:391–393silently drops a malformeddependencies.github-appconfig with only a debug log, producing a compile-time success followed by a confusing runtime authentication failure.checkout_manager.go:809–810returns a hard error for the identical condition.Locations:
pkg/workflow/frontmatter_extraction_metadata.go:388–393— silent ignore pathpkg/workflow/compiler_orchestrator_tools.go:210–214— caller that gets the degraded resultImpact:
Recommendation: Change
extractAPMDependenciesFromFrontmatterto return an error on invalidgithub-appconfig, or add aconsole.FormatWarningMessage+c.IncrementWarningCount()call incompiler_orchestrator_tools.gowhen packages are returned butGitHubAppis nil despitegithub-app:being present in frontmatter.Validation:
apm_dependencies_test.goasserting that missingapp-idproduces a user-visible error/warning (not just silent nil)checkout_manager.goerror message styleEstimated Effort: Small
Task 2: Add APM GitHub App token revocation step
Issue Type: Security — Token Lifecycle
Problem: The APM GitHub App token minted with
id: apm-app-tokenincompiler_activation_job.gois never revoked. Every other token mint path in the codebase has abuildGitHubAppTokenInvalidationStepcounterpart.Locations:
pkg/workflow/apm_dependencies.go— addbuildAPMAppTokenInvalidationStep()functionpkg/workflow/compiler_activation_job.go:424+— call it after the artifact upload stepImpact:
Before: No revocation step after APM pack + upload.
After:
always()-gated invalidation step referencingsteps.apm-app-token.outputs.token.Validation:
apm_dependencies_compilation_test.goasserting invalidation step present whenGitHubApp != nilif: always()condition is generatedEstimated Effort: Small–Medium (new function + test)
Task 3: Sort repository list in
buildGitHubAppTokenMintStepIssue Type: Non-deterministic Output / Code Inconsistency
Problem:
safe_outputs_app_config.go:158–163iteratesapp.Repositoriesin declaration order for the multi-repo block-scalar case;apm_dependencies.go:54–60(written later) correctly sorts. Reordering repos in frontmatter causes spurious lock file diffs.Location:
pkg/workflow/safe_outputs_app_config.go:158–163Impact:
Recommendation: Apply
sort.Stringson a copy ofapp.Repositoriesbefore generating the block scalar (mirrors the APM implementation exactly).Validation:
compiler_safe_outputs_job_test.goverifying that[repo-b, repo-a]and[repo-a, repo-b]produce identical compiled outputEstimated Effort: Small (3 lines)
Success Metrics
This Run
Score Reasoning: +4 findings quality (2 HIGH + 1 MEDIUM, both high-quality with concrete evidence and clear fix paths); +2 coverage (focused on new commit, 100% coverage of new APM github-app code path); +2 task generation (all 3 tasks are actionable, scoped, and include validation checklists).
Historical Context
Strategy Performance (last 8 runs)
Cumulative Statistics
Recommendations
Immediate Actions
apm_dependencies.go+compiler_activation_job.go) — HIGH security, small effort, follows an established pattern already used 4× elsewhere in the codebasedependencies.github-appvalidation error to user (frontmatter_extraction_metadata.goorcompiler_orchestrator_tools.go) — HIGH UX, ensures consistency withcheckout.github-appbehaviorbuildGitHubAppTokenMintStep(safe_outputs_app_config.go:158–163) — MEDIUM, 3-line fix, eliminates spurious lock file diffsLong-term Improvements
buildAppTokenMintStep(id, app, permissions, fallback)+buildAppTokenInvalidationStep(id)pair to make future token minting impossible to implement incorrectly.extractAPMDependenciesFromFrontmattererror propagation: The function currently returns(result, nil)— addingerrorto the return type would allow the extraction path to match the validation contract ofcheckout_manager.go.Next Run Preview
Suggested Focus Areas
add_integration_test.go:985SHA pin@c93eec8TODO has been updated following PR Merge safe-outputs.allowed-domains and allowed-url-domains; rename default-redaction to default-safe-outputs #21114 merger (from run 22, MEDIUM, still unfixed)safe_outputs_config.go:174backward-compat gap for the renamedallowed-url-domains→allowed-domainskey (from run 22, MEDIUM, still unfixed)codemod_github_app.go,codemod_mcp_scripts.go, etc.) for edge cases in YAML line-by-line transformsStrategy Evolution
The cached half of run 24 should use the new-feature validation-gap approach (score 8) from today to check the other new codemods and changesets in commit
2181d15. New exploration could target the changesetminor-preserve-branch-name-in-safe-outputs.mdorminor-decouple-status-comment.mdto find similar validation and lifecycle gaps.References:
Generated by Sergo — The Serena Go Expert | Run ID: 23168542999 | Strategy: yaml-injection-revisit-plus-new-feature-validation-gap
Beta Was this translation helpful? Give feedback.
All reactions