T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/helm_chart_linter.py:391
- Finding
- Resource-limit validation can be bypassed by an empty or requests-only resources block## Vulnerability Details **File Location**: `scripts/helm_chart_linter.py:391-397` **Vulnerability Type**: Incomplete security validation leading to false-negative results **Risk Level**: Medium ### Vulnerable 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 issues ``` ### Technical Analysis The SEC004 rule is documented as verifying that resource limits are defined. Its implementation suppresses the warning whenever either `limits:` or `resources:` appears anywhere in the template. A Kubernetes workload can contain a `resources:` block with only `requests`, 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 1. A chart author creates a Deployment, StatefulSet, DaemonSet, Job, or CronJob template. 2. The workload contains a requests-only block such as: ```yaml resources: requests: cpu: 100m memory: 128Mi ``` 3. No `resources.limits` values are configured. 4. The chart is checked with the `security`, `lint`, or `validate` command. 5. Because the template contains the substring `resources:`, the conditional expression eva ...[truncated 720 chars]
- 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.limits` mapping 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.
