Skip to content

[uk-ai-resilience] [security] Fix GraphQL injection in project_command.go (Semgrep #643/#644, CWE-89) #46277

Description

@github-actions

Summary

Two new Semgrep code-scanning alerts (2026-07-14) flag GraphQL string injection in pkg/cli/project_command.go that are not covered by any existing open issue. The existing issue #43831-series covers older alerts #627/#628 only.

Tier & Risk Scoring

  • Tier: B — Open With Conditions
  • Exposure amplification: Medium (elevated in agentic context — workflows run with elevated GitHub tokens)
  • Patchability: Moderate
  • Detectability: Medium
  • Operational fragility: Low
  • Overall risk: Medium
  • Remediation priority: Medium (30-day SLA)

Affected Locations

Alert File Line Message
#644 pkg/cli/project_command.go 646 ownerLogin interpolated into GraphQL query; escapeGraphQLString() used but fragile
#643 pkg/cli/project_command.go 235 owner/org login values interpolated via fmt.Sprintf; escapeGraphQLString() used but fragile

Remediation Action

Replace fmt.Sprintf-based GraphQL string interpolation with proper GraphQL variables using gh api graphql -F owner=... so user-supplied values are never interpolated into the query body. This fully eliminates injection risk and is the recommended approach per the Semgrep rule.

// Before (fragile)
query := fmt.Sprintf(`query { organization(login: "%s") { ... } }`, escapeGraphQLString(ownerLogin))

// After (safe)
query := `query($owner: String!) { organization(login: $owner) { ... } }`
// Pass owner as a GraphQL variable

Exception Governance

  • Threat hypothesis: Malformed org/owner login values could alter GraphQL query semantics; in an agentic context this could be used to exfiltrate organisation data or bypass access checks.
  • Exploit acceleration claim: Low — escapeGraphQLString() provides partial mitigation; org names are also constrained in practice.
  • Expiry date: 2026-08-17 (30-day SLA)
  • Mitigation plan: Implement GraphQL variables pattern; add unit test with crafted login value.

Discussion Report

Full UK AI governance report: see weekly discussion report for 2026-07-17

References

Generated by UK AI Operational Resilience · 65.7 AIC · ⌖ 8.06 AIC · ⊞ 5.1K ·

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions