T09 · Insecure Skill Coding Practices
- Location
scripts/main.py:64- Finding
Unsafe First-Match Classification of Chemical Mixtures
- Content
View full analysis
Vulnerability Details
File Location:
scripts/main.py:64-73; documented behavior contradicted atSKILL.md:29-31
Vulnerability Type: Unsafe input classification and missing mixture validation
Risk Level: HighVulnerable Code
python def lookup(self, chemical): """Look up disposal category for chemical.""" chemical_lower = chemical.lower().strip() for category, info in self.WASTE_CATEGORIES.items(): if any(chemical_lower in accept or accept in chemical_lower for accept in info["accepts"]): return info return NoneThe documented workflow promises behavior that is not implemented:
markdown 4. **Mixture handling:** If the user provides a mixture (e.g., "chloroform + ethanol"), identify the most hazardous component and assign the container for that component. Emit a note: "Mixed waste containing halogenated solvents must go into the halogenated (orange) container regardless of other components." 5. If the chemical is not found, state that clearly and suggest the closest category based on chemical class. 6. If inputs are incomplete, state which fields are missing and request only the minimum additional information.Technical Analysis
The lookup algorithm uses bidirectional substring matching:
python chemical_lower in accept or accept in chemical_lowerIt then returns the first matching category according to dictionary insertion order. It does not tokenize mixtures, identify every component, check incompatibilities, rank hazards, or apply the documented halogenated-waste precedence rule.
For example, the input
ethanol + nitric acidcontains recognized components from two different categories. Thenon_halogenatedcategory is evaluated before theacidcategory, so the occurrence ofethanolcauses an immediate recommendation for the red non-halogenated organic-waste container. The nitric acid ...[truncated 1836 chars]- Remediation
View remediation
Remediation Suggestions
- Replace bidirectional substring matching with normalized exact alias matching. Map each accepted alias to a canonical chemical and category.
- Parse explicitly supported mixture separators, including
+, commas, semicolons, and words such asand, before classification. - Classify every mixture component independently. Do not return after the first match.
- Implement an explicit, reviewed compatibility and precedence policy. At minimum, enforce the documented rule that any recognized halogenated solvent causes assignment to the halogenated-waste category.
- Do not assume that selecting a single “most hazardous” component is safe for arbitrary mixtures. Reject incompatible, ambiguous, partially recognized, or unsupported mixtures and direct the user to the institution's environmental health and safety office.
- Display all recognized components, unresolved components, and the rule used to derive the final recommendation.
- Add regression tests for:
- Halogenated and non-halogenated solvent mixtures.
- Acid and organic-solvent mixtures.
- Acid and base mixtures.
- Oxidizer and organic mixtures.
- Unknown components combined with known components.
- Partial names, negated descriptions, and aliases.
- Inputs containing multiple separators.
- Keep
SKILL.mdsynchronized with actual executable behavior and avoid documenting safety controls until they are implemented and tested.
