Skip to content

fix: Helm YAML Injection - #1068

Open
dennisvankekem wants to merge 2 commits into
mainfrom
APL-2056
Open

fix: Helm YAML Injection#1068
dennisvankekem wants to merge 2 commits into
mainfrom
APL-2056

Conversation

@dennisvankekem

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI lite review requested due to automatic review settings August 19, 2026 09:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens input validation for Kubernetes NetworkPolicy selector labels to mitigate Helm/YAML injection risks by constraining label name/value fields to Kubernetes-compatible regex patterns and extending test coverage around those constraints.

Changes:

  • Add kubernetesLabelName and kubernetesLabelValue regex definitions (max 63 chars) to the shared OpenAPI definitions.
  • Update the netpol OpenAPI schema to use these new definitions for toLabelName/toLabelValue and fromLabelName/fromLabelValue.
  • Extend unit and API authz tests to cover valid/invalid Kubernetes label names/values and guard against regex ReDoS.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/openapi/definitions.yaml Introduces reusable regex definitions for Kubernetes label name/value.
src/openapi/netpol.yaml Applies the new label name/value definitions to netpol selector fields via $ref.
src/patterns.test.ts Adds ReDoS cases and validity tests for the new label patterns.
src/api-v2.authz.test.ts Adds API-level validation tests ensuring invalid label values are rejected.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +846 to +853
kubernetesLabelName:
type: string
maxLength: 63
pattern: '^[A-Za-z0-9](?:[-._A-Za-z0-9]{0,61}[A-Za-z0-9])?$'
kubernetesLabelValue:
type: string
maxLength: 63
pattern: '^$|^[A-Za-z0-9](?:[-._A-Za-z0-9]{0,61}[A-Za-z0-9])?$'
Comment thread src/patterns.test.ts
Comment on lines +257 to +271
expectInvalid('kubernetesLabelValue', [
'-app',
'app-',
'.app',
'app.',
'_app',
'app_',
'app value',
'foo\nbar',
'foo\r\nbar',
'{{ malicious }}',
'foo: bar',
'---',
'a'.repeat(64),
])
Comment thread src/api-v2.authz.test.ts
Comment on lines +1193 to +1194
it.each(['foo\nbar', 'foo\r\nbar', '{{ malicious }}', 'foo: bar', 'foo bar', '---'])(
'rejects invalid label value %p',
Comment thread src/patterns.test.ts
Comment on lines +281 to +296
expectInvalid('kubernetesLabelName', [
'',
'-app',
'app-',
'.app',
'app.',
'_app',
'app_',
'app name',
'foo\nbar',
'foo\r\nbar',
'{{ malicious }}',
'foo: bar',
'---',
'a'.repeat(64),
])
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