T09 · Insecure Skill Coding Practices
- Location
examples/rest-api-examples.md:237- Finding
Cypher Injection Through Direct Interpolation of Request Parameters
- Content
View full analysis
(c:Category {{id:'{category}'}})") if min_price > 0 or max_price < 999999: price_filter = f"p.price >= {min_price} AND p.price <= {max_price}" filters.append(f"WHERE {price_filter}") where_clause = " ".join(filters) if filters else "" order_by = f"ORDER BY p.{sort.lstrip('-')}" + (" DESC" if sort.startswith("-") else "") full_query = f""" {query} {where_clause} {order_by} SKIP {offset} LIMIT {limit} """ products = db.execute_query(full_query) ``` ```python query = f""" MATCH (p:Product {{id:'{product_id}'}})-[:PURCHASED_WITH]-(rec:Product) WITH rec, COUNT(*) as frequency ORDER BY frequency DESC LIMIT {limit} RETURN rec """ recommendations = db.execute_query(query) ``` ### Technical Analysis The examples insert HTTP request parameters directly into Cypher statements using Python formatted strings. The affected values include: - `user_id`, originating from a URL path parameter. - `category`, originating from a query parameter. - `sort`, originating from a query parameter an ...[truncated 2292 chars]- Remediation
View remediation
