T09 · Insecure Skill Coding Practices
- Location
scripts/ontology.py:119- Finding
Graph mutations are persisted without enforcing declared schema constraints
- Content
View full analysis
Vulnerability Details
File Location:
scripts/ontology.py:119-135,scripts/ontology.py:171-184,scripts/ontology.py:200-212, andscripts/ontology.py:493-527
Vulnerability Type: Schema validation bypass leading to plaintext sensitive-data storage and invalid graph state
Risk Level: MediumVulnerable Code
python def create_entity(type_name: str, properties: dict, graph_path: str, entity_id: str = None) -> dict: """Create a new entity.""" entity_id = entity_id or generate_id(type_name) timestamp = datetime.now(timezone.utc).isoformat() entity = { "id": entity_id, "type": type_name, "properties": properties, "created": timestamp, "updated": timestamp } record = {"op": "create", "entity": entity, "timestamp": timestamp} append_op(graph_path, record) return entitypython def update_entity(entity_id: str, properties: dict, graph_path: str) -> dict | None: """Update entity properties.""" entities, _ = load_graph(graph_path) if entity_id not in entities: return None timestamp = datetime.now(timezone.utc).isoformat() record = {"op": "update", "id": entity_id, "properties": properties, "timestamp": timestamp} append_op(graph_path, record) entities[entity_id]["properties"].update(properties) entities[entity_id]["updated"] = timestamp return entities[entity_id]python def create_relation(from_id: str, rel_type: str, to_id: str, properties: dict, graph_path: str): """Create a relation between entities.""" timestamp = datetime.now(timezone.utc).isoformat() record = { "op": "relate", "from": from_id, "rel": rel_type, "to": to_id, "properties": properties, "timestamp": timestamp } append_op(graph_path, record) return reco ...[truncated 4680 chars]- Remediation
View remediation
Remediation Suggestions
- Require and load a schema before every mutation that depends on schema guarantees.
- Construct a proposed in-memory graph state and validate it before calling
append_op. - Reject create and update operations containing forbidden properties, missing required properties, invalid enum values, or invalid property types.
- Reject relation creation when either endpoint does not exist or when endpoint types, cardinality, or acyclicity constraints would be violated.
- Ship a secure default schema containing the documented Credential restrictions and core type constraints.
- Make mutation and persistence atomic: append only after validation succeeds, and return a nonzero exit status on rejection.
- Add explicit secret-pattern defenses for credential entities so obvious secret-bearing fields cannot be persisted even when a custom schema omits the restriction.
- Implement actual rollback for multi-step graph transformations or revise the documentation to state that rollback is unsupported.
- Add regression tests confirming that forbidden Credential fields, dangling relations, invalid cardinality, cycles, and missing required properties are rejected before any data reaches the JSONL file.
