# Business Logic Errors (CWE-840) The product does not properly implement the business logic rules, which may allow users to manipulate the system in unintended ways. **Stack:** Python - Prevalence: Média 3 linguagens cobertas - Impact: Alto 3 regras de severidade alta - Prevention: Documentada 3 exemplos de correção **OWASP:** Broken Access Control (A01:2021-Broken Access Control) - #1 ## Description Business logic errors occur when the application's implementation doesn't correctly enforce the intended business rules. Unlike technical vulnerabilities, these are flaws in the application's design or logic. ## Prevention Estratégias de prevenção para Business Logic Errors baseadas em 1 regras de detecção do Shoulder. ### Python Calculate totals server-side using database prices instead of client-submitted values ## Warning Signs - [HIGH] client-controlled business-critical values (price, quantity, discount) flowing to payment or busines ## Consequences - Burlar mecanismo de proteção - Obter privilégios - Modificar dados da aplicação ## Mitigations - Documente claramente as regras de negócio e suas implicações de segurança - Teste casos extremos e fluxos de trabalho incomuns - Implemente validação no servidor de todas as regras de negócio ## Detection - Total rules: 3 - Languages: go, javascript, typescript, python ## Rules by Language ### Python (1 rules) - **Business Logic Bypass** [HIGH]: Detects client-controlled business-critical values (price, quantity, discount) flowing to payment or business operations without server-side validation. - Remediation: Calculate totals server-side using database prices instead of client values. ```python @app.post('/checkout') async def checkout(item_id: int, quantity: int): product = Product.query.get(item_id) total = product.price * quantity stripe.Charge.create(amount=total) ``` Learn more: https://shoulder.dev/learn/python/cwe-840/business-logic-bypass