Business Logic Errors
The product does not properly implement the business logic rules, which may allow users to manipulate the system in unintended ways.
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.
So behebst du diese Schwachstelle
Präventionsstrategien für Business Logic Errors basierend auf 3 Shoulder-Erkennungsregeln.
Calculate financial values server-side from trusted data sources instead of accepting client-submitted totals
package main import ( "net/http" "strconv" ) func checkoutHandler(w http.ResponseWriter, r *http.Request) { - total, _ := strconv.ParseFloat(r.FormValue("total"), 64) + productID := r.FormValue("product_id") + qty, err := strconv.Atoi(r.FormValue("quantity")) + if err != nil || qty <= 0 { + http.Error(w, "Invalid quantity", http.StatusBadRequest) + return + } + + var product Product + if err := db.First(&product, productID).Error; err != nil { + http.Error(w, "Product not found", http.StatusNotFound) + return + } + + total := product.Price * float64(qty) processPayment(total) w.Write([]byte("Payment processed")) }
Calculate totals and prices server-side using database values instead of client-submitted data
app.post('/checkout', async (req, res) => { - const { total } = req.body; + const product = await Product.findById(req.body.productId); + const total = product.price * req.body.quantity; await stripe.charges.create({ amount: total, currency: 'usd' }); });
Calculate totals server-side using database prices instead of client-submitted values
from flask import request @app.route('/checkout', methods=['POST']) def checkout(): - price = float(request.form['price']) - quantity = int(request.form['quantity']) - stripe.Charge.create(amount=int(price * quantity * 100)) + item_id = int(request.form['item_id']) + quantity = int(request.form['quantity']) + product = Product.query.get(item_id) + total = product.price * quantity + stripe.Charge.create(amount=int(total * 100))
Finden Sie Schwachstellen in Ihrem Code
Verwenden Sie Shoulder, um Ihren Code nach Business Logic Errors-Mustern zu scannen. 3 Regeln.
# Scan with Shoulder CLI npx @shoulderdev/cli trust --cwe=840 # Or scan entire project npx @shoulderdev/cli trust .
Erkennungsregeln (3)
Worauf bei Code-Reviews zu achten ist
Diese Muster weisen auf potenzielle Business Logic Errors-Schwachstellen hin. Achten Sie bei Code-Reviews und Sicherheitsaudits darauf.
Scanne deine Codebasis nach Business Logic Errors
Shoulder CLI findet anfällige Muster in deiner gesamten Codebasis.