T09 · Insecure Skill Coding Practices
- Location
scripts/helm_chart_linter.py:391- Finding
Resource-limit validation can be bypassed by an empty or requests-only resources block
- Content
View full analysis
Vulnerability Details
File Location:
scripts/helm_chart_linter.py:391-397
Vulnerability Type: Incomplete security validation leading to false-negative results
Risk Level: MediumVulnerable Code
python def check_resource_limits(chart_dir: str) -> list: issues = [] for tpl_path in find_template_files(chart_dir): text = read_file(tpl_path) # Only check files that look like Deployment/StatefulSet/DaemonSet if not re.search(r'kind\s*:\s*(Deployment|StatefulSet|DaemonSet|Job|CronJob)', text): continue if 'limits:' not in text and 'resources:' not in text: issues.append(Issue('SEC004', 'warning', f'No resource limits defined in {os.path.basename(tpl_path)}', tpl_path)) return issuesTechnical Analysis
The SEC004 rule is documented as verifying that resource limits are defined. Its implementation suppresses the warning whenever either
limits:orresources:appears anywhere in the template.A Kubernetes workload can contain a
resources:block with onlyrequests, an empty resources block, or an unrelated textual occurrence without defining any container resource limits. All such cases satisfy the current substring test and incorrectly pass SEC004. The implementation also searches the complete template as unstructured text, so limits belonging to one container can conceal missing limits on other containers or init containers.Attack Path
-
A chart author creates a Deployment, StatefulSet, DaemonSet, Job, or CronJob template.
-
The workload contains a requests-only block such as:
yaml resources: requests: cpu: 100m memory: 128Mi -
No
resources.limitsvalues are configured. -
The chart is checked with the
security,lint, orvalidatecommand. -
Because the template contains the substring
resources:, the conditional expression eva ...[truncated 720 chars]
-
- Remediation
View remediation
Remediation Suggestions
- Render Helm templates and parse the resulting Kubernetes YAML structurally rather than relying on document-wide substring searches.
- For every workload, inspect every regular container and init container independently.
- Require a non-empty
resources.limitsmapping with the desired CPU and memory keys. - Do not treat the presence of
resources:or limits assigned to another container as sufficient. - Report the workload, container name, file, and document location for each missing limit.
- Add regression tests for requests-only resources, empty resources, limits on only one of multiple containers, limits in comments, and templated resources.
