# 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:** Go - Prevalence: Średnia Pokryto 3 języków - Impact: Wysoki 3 reguł o wysokim poziomie - Prevention: Udokumentowane 3 przykładów poprawek **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 Strategie zapobiegania dla Business Logic Errors oparte na 1 regułach detekcji Shoulder. ### Go Calculate financial values server-side from trusted data sources instead of accepting client-submitted totals ## Consequences - Obejście mechanizmu ochrony - Uzyskanie uprawnień - Modyfikacja danych aplikacji ## Mitigations - Wyraźnie dokumentuj reguły biznesowe i ich implikacje bezpieczeństwa - Testuj przypadki brzegowe i nietypowe przepływy pracy - Wdroż walidację wszystkich reguł biznesowych po stronie serwera ## Detection - Total rules: 3 - Languages: go, javascript, typescript, python ## Rules by Language ### Go (1 rules) - **Business Logic Bypass** [HIGH]: Client-controlled financial values flow to payment operations without server-side calculation. - Remediation: Fetch prices from the database instead of trusting client values. ```go func checkout(c *gin.Context) { productID := c.PostForm("product_id") var product Product db.First(&product, productID) total := product.Price * float64(quantity) processPayment(total) } ``` Learn more: https://shoulder.dev/learn/go/cwe-840/business-logic-bypass