AUTHORIZED SECURITY ASSESSMENT • COORDINATED DISCLOSURE
Root-Cause Analysis: Unauthenticated Data Exposure & Input Boundary Flaws in an Agricultural Ration Solver API
Author: Fata Fatikhul Karim • Target Stack: Express.js / REST API + Client Simplex Solver • Findings: 8 Findings (7 Vulnerabilities: 2 High, 4 Medium, 1 Low; plus 1 Informational)
1. Context & Threat Model
Agricultural ration formulation platforms compute least-cost or nutrient-balanced livestock feed mixtures based on biological parameters such as animal live body weight (BB), feed Dry Matter percentage (DM%), crude protein, and mineral requirements. During an authorized security review of a web-based ration solver, I evaluated the system across two intersecting threat surfaces:
- Access Control & Multi-Tenant Privacy (CWE-306 / OWASP API1:2023 & API5:2023): Whether calculation histories (
GET /api/history) and shared feed catalog mutations (POST /api/feeds) were properly gated by authentication and scoped to session owners. - Domain-Math & Input Boundary Integrity (CWE-20 / CWE-400): Whether both the client-side linear/simplex solver and the backend API enforced nutritional and biological bounds before executing matrix iterations or persisting records.
2. Coordinated Disclosure Timeline & CVSS v3.1 Vectors (All 8 Findings)
All 8 findings were reproduced on October 9, 2026, mapped to MITRE CWE identifiers and FIRST CVSS v3.1 base scores/vectors, and re-tested against the production environment after the maintainer deployed fixes between October 12 and October 14, 2026:
| ID | Finding & Affected Component | CWE | CVSS v3.1 Score & Vector | Reported | Vendor Ack | Deployed & Re-tested |
|---|---|---|---|---|---|---|
SOLVER-01 |
Unauthenticated Calculation History Exposure on GET /api/history (38 user records readable without session token) |
CWE-306 |
7.5 HIGHCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N |
2026-10-09 | 2026-10-10 | Deployed & Re-tested (2026-10-12) |
SOLVER-02 |
Unvalidated Numeric Mutation on POST /api/feeds (DM -500% accepted with HTTP 200, causing 2.3e+289 kg float divergence) |
CWE-20 |
7.5 HIGHCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N |
2026-10-09 | 2026-10-10 | Deployed, Test UUIDs Purged & Re-tested (2026-10-12) |
SOLVER-03 |
Client-Side Solver Thread Freeze & Missing Server Bounds on Non-Positive Body Weight (BB <= 0 with empty HTML min/max) |
CWE-400 |
6.5 MEDCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H |
2026-10-09 | 2026-10-10 | Client + Server Guard Deployed & Re-tested (2026-10-13) |
SOLVER-04 |
Unauthenticated Write Access & Missing DELETE/PUT Auth on Shared Feed Catalog (POST /api/feeds) |
CWE-306 |
5.3 MEDCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N |
2026-10-09 | 2026-10-10 | Deployed & Re-tested (2026-10-13) |
SOLVER-05 |
Global Wildcard CORS Policy (Access-Control-Allow-Origin: * across all API routes) |
CWE-942 |
5.3 MEDCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N |
2026-10-09 | 2026-10-10 | Deployed & Re-tested (2026-10-14) |
SOLVER-07 |
Missing HTTP Security Headers (No Content-Security-Policy, HSTS, or X-Frame-Options) |
CWE-693 |
4.3 MEDCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N |
2026-10-09 | 2026-10-10 | Deployed & Re-tested (2026-10-14) |
SOLVER-08 |
Backend Stack Fingerprinting via Default x-powered-by: Express Header |
CWE-200 |
3.7 LOWCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N |
2026-10-09 | 2026-10-10 | Deployed & Re-tested (2026-10-14) |
SOLVER-06 |
Cloudflare __cf_bm Cookie SameSite=None + Wildcard Domain Observation (Triaged as None / Informational: expected Cloudflare Bot Management CDN behavior, not an application session flaw) |
CWE-1275 |
0.0 NONECVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N |
2026-10-09 | 2026-10-10 | Triaged as None / Informational (2026-10-10) |
3. Root-Cause Analysis, Pre-Patch PoCs & Post-Patch Verification Logs
Below are the vulnerable patterns, pre-patch reproduction commands (October 9, 2026), and post-patch re-test verification outputs (October 12–14, 2026):
// [SOLVER-01 / CWE-306] Unauthenticated Calculation History Exposure (7.5 HIGH)
// Pre-Patch PoC (2026-10-09):
// $ curl -i https://<redacted-target>/api/history
// HTTP/1.1 200 OK
// Content-Type: application/json; charset=utf-8
// [{"id":"...","animal":"Sapi Potong","resultKg":2.3e+289,...}] (38 records returned without auth)
// [SOLVER-02 (CWE-20, 7.5 HIGH) & SOLVER-04 (CWE-306, 5.3 MED)] Unvalidated & Unauthenticated Feed Mutation
// Pre-Patch PoC (2026-10-09):
// $ curl -i -X POST https://<redacted-target>/api/feeds \
// -H "Content-Type: application/json" \
// -d '{"name":"VerificationFeed","category":"Mineral","dryMatterPct":-500}'
// HTTP/1.1 200 OK -> Created record IDs 4e856b17... & a030ba7f... without auth or DM% bounds check.
// [SOLVER-03 / CWE-400] Client-Side Solver Thread Freeze & Missing Server Bounds on BB <= 0 (6.5 MEDIUM)
// Root Cause: Step 1 HTML input `<input id="bodyWeight" type="number">` had empty min/max attributes,
// and the client JavaScript solver function `solveRation(bodyWeightKg, feeds)` divided directly by
// `targetDryMatter = bodyWeightKg * 0.03` without guarding `bodyWeightKg <= 0`, entering a non-terminating
// pivot loop in the browser UI thread (and the backend solver endpoint lacked positive weight validation).
// [SOLVER-05, 07, 08 & 06] Pre-Patch Header & CORS Inspection (2026-10-09):
// $ curl -i -H "Origin: https://evil.example" https://<redacted-target>/api/feeds
// HTTP/1.1 200 OK
// X-Powered-By: Express <-- [SOLVER-08: 3.7 LOW]
// Access-Control-Allow-Origin: * <-- [SOLVER-05: 5.3 MED]
// Set-Cookie: __cf_bm=...; Domain=.<target>; SameSite=None; Secure; HttpOnly <-- [SOLVER-06: 0.0 NONE / Cloudflare Bot Mgmt]
// (Missing Content-Security-Policy, Strict-Transport-Security, X-Frame-Options) <-- [SOLVER-07: 4.3 MED]
Post-Patch Verification Log (Re-tested 2026-10-12 to 2026-10-14)
# 1. Re-test SOLVER-01 (2026-10-12): Unauthenticated history request now blocked with 401
$ curl -i https://<redacted-target>/api/history
HTTP/1.1 401 Unauthorized
Content-Security-Policy: default-src 'self'
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Frame-Options: DENY
Content-Type: application/json; charset=utf-8
{"error":"Authentication required"}
# 2. Re-test SOLVER-02 & SOLVER-04 (2026-10-12): Unauthenticated POST rejected (401);
# Authenticated POST with negative Dry Matter (-500%) rejected by Zod schema (400)
$ curl -i -X POST https://<redacted-target>/api/feeds \
-H "Authorization: Bearer <valid-session-jwt>" \
-H "Content-Type: application/json" \
-d '{"name":"VerificationFeed","category":"Mineral","dryMatterPct":-500}'
HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=utf-8
{"error":"Invalid feed parameters","details":[{"path":["dryMatterPct"],"message":"Number must be greater than or equal to 0.5"}]}
# 3. Re-test SOLVER-05, 07, 08 (2026-10-14): Untrusted Origin not reflected, X-Powered-By removed, CSP/HSTS active
$ curl -I -H "Origin: https://evil.example" https://<redacted-target>/api/feeds
HTTP/1.1 200 OK
Content-Security-Policy: default-src 'self'
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Vary: Origin
4. Defensive Remediation (Client Guard + Domain-Separated Backend Schemas)
Notice the separation of domain responsibilities: feed ingredient catalog definitions validate nutritional composition (dryMatterPct: 0.5% – 100%), whereas ration solver requests validate animal physiological bounds (bodyWeightKg: 1.0 – 2500 kg, consistent with National Research Council / NRC Nutrient Requirements of Beef and Dairy Cattle reference ranges from neonatal calves to mature breeding bulls), paired with a client-side pre-solver guard to prevent browser thread hangs:
// ✅ 1. CLIENT-SIDE SOLVER GUARD (Mitigates SOLVER-03 browser main-thread freeze)
export function validateAndRunClientSolver(bodyWeightKg, selectedFeeds) {
if (!Number.isFinite(bodyWeightKg) || bodyWeightKg < 1.0 || bodyWeightKg > 2500) {
throw new RangeError('Livestock body weight (BB) must be between 1.0 kg and 2,500 kg.');
}
return runSimplexRationSolver(bodyWeightKg, selectedFeeds);
}
// ✅ 2. SERVER-SIDE EXPRESS & ZOD SCHEMAS (Mitigates SOLVER-01..05, 07, 08)
import { z } from 'zod';
import helmet from 'helmet';
import cors from 'cors';
const ALLOWED_ORIGINS = ['https://app.authorized-domain.example'];
app.disable('x-powered-by');
app.use(helmet());
app.use(cors({
origin: (origin, cb) => (!origin || ALLOWED_ORIGINS.includes(origin) ? cb(null, true) : cb(null, false)),
methods: ['GET', 'POST']
}));
// Schema A: Feed Ingredient Catalog Item (NRC Dry Matter range: 0.5% liquid whey to 100% mineral premix)
const FeedIngredientSchema = z.object({
name: z.string().trim().min(2).max(80),
category: z.enum(['Forage', 'Concentrate', 'Mineral', 'Vitamin']),
dryMatterPct: z.number().min(0.5).max(100)
});
// Schema B: Ration Formulation Calculation Request (NRC cattle/livestock live weight range: 1 - 2,500 kg)
const RationSolveRequestSchema = z.object({
bodyWeightKg: z.number().min(1.0).max(2500),
feedIds: z.array(z.string().uuid()).min(1).max(30)
});
app.post('/api/feeds', requireAuth, async (req, res) => {
const parsed = FeedIngredientSchema.safeParse(req.body);
if (!parsed.success) {
return res.status(400).json({ error: 'Invalid feed parameters', details: parsed.error.issues });
}
const feed = await db.feeds.create({ ...parsed.data, createdBy: req.user.id });
return res.status(201).json(feed);
});
app.post('/api/solve', requireAuth, async (req, res) => {
const parsed = RationSolveRequestSchema.safeParse(req.body);
if (!parsed.success) {
return res.status(400).json({ error: 'Invalid ration solver parameters', details: parsed.error.issues });
}
const result = await computeOptimalRation(parsed.data, req.user.id);
return res.status(200).json(result);
});
app.get('/api/history', requireAuth, async (req, res) => {
const records = await db.history.findMany({ where: { userId: req.user.id } });
return res.status(200).json(records);
});
Automated Regression Test Suite (Jest + Supertest • Covers SOLVER-01..05, 07, 08)
import request from 'supertest';
import jwt from 'jsonwebtoken';
import { app } from '../src/app';
import { validateAndRunClientSolver } from '../src/client/solver';
const TEST_JWT_SECRET = process.env.JWT_SECRET || 'test-only-ephemeral-secret';
let validUserToken;
beforeAll(() => {
// Sign a real test JWT with the test environment secret so requireAuth passes (avoiding false 401s on 400 schema tests)
validUserToken = jwt.sign({ id: 'user-uuid-001', role: 'formulator' }, TEST_JWT_SECRET, { expiresIn: '15m' });
});
const validFeed = {
name: 'Napier Grass Forage',
category: 'Forage',
dryMatterPct: 22.5
};
describe('Ration Solver Security Regression Suite (SOLVER-01 through SOLVER-08)', () => {
it('SOLVER-01: rejects unauthenticated access to GET /api/history with 401', async () => {
const res = await request(app).get('/api/history');
expect(res.status).toBe(401);
});
it('SOLVER-02: rejects negative Dry Matter percentage (-500%) on POST /api/feeds with 400', async () => {
const res = await request(app)
.post('/api/feeds')
.set('Authorization', `Bearer ${validUserToken}`)
.send({ ...validFeed, dryMatterPct: -500 });
expect(res.status).toBe(400);
});
it('SOLVER-03: rejects non-positive bodyWeightKg (BB <= 0) in both client guard and POST /api/solve', async () => {
expect(() => validateAndRunClientSolver(0, [validFeed])).toThrow(RangeError);
expect(() => validateAndRunClientSolver(-50, [validFeed])).toThrow(RangeError);
const res = await request(app)
.post('/api/solve')
.set('Authorization', `Bearer ${validUserToken}`)
.send({ bodyWeightKg: 0, feedIds: ['550e8400-e29b-41d4-a716-446655440000'] });
expect(res.status).toBe(400);
});
it('SOLVER-04: rejects unauthenticated POST /api/feeds with 401', async () => {
await request(app).post('/api/feeds').send(validFeed).expect(401);
});
it('SOLVER-05: allows trusted Origin and omits Access-Control-Allow-Origin for untrusted Origin', async () => {
const allowedRes = await request(app)
.get('/api/feeds')
.set('Origin', 'https://app.authorized-domain.example');
expect(allowedRes.headers['access-control-allow-origin']).toBe('https://app.authorized-domain.example');
const untrustedRes = await request(app)
.get('/api/feeds')
.set('Origin', 'https://evil.example');
expect(untrustedRes.headers['access-control-allow-origin']).toBeUndefined();
});
it('SOLVER-07: sends core HTTP security headers (CSP, HSTS, X-Frame-Options)', async () => {
const res = await request(app).get('/');
['content-security-policy', 'strict-transport-security', 'x-frame-options']
.forEach((h) => expect(res.headers[h]).toBeDefined());
});
it('SOLVER-08: hides x-powered-by stack fingerprinting header', async () => {
const res = await request(app).get('/');
expect(res.headers['x-powered-by']).toBeUndefined();
});
});
5. Conclusion & Engineering Takeaways
This assessment illustrates three practical lessons for full-stack and application security engineering:
- Domain-Separated Schema Invariants: Nutritional composition parameters (
dryMatterPcton feed definitions) and physiological parameters (bodyWeightKgon solver requests) must be validated against domain-grounded bounds (such as NRC livestock nutrition tables) at both the client solver entry point and the backend API boundary. - Default-Deny Authentication & Tenant Scoping: Read endpoints returning historical calculations (
GET /api/history) and shared catalog mutations (POST /api/feeds) must enforce authentication middleware and tenant ownership filters by default. - Rigorous False-Positive Triage: Initial observation of
SameSite=Noneon the__cf_bmcookie (`SOLVER-06`) was triaged to 0.0 None (Informational) upon verifying via Cloudflare documentation that__cf_bmis a CDN-managed bot-mitigation cookie rather than an application session identifier.
6. Standards & References
- OWASP API Security Top 10 (2023): API1:2023 Broken Object Level Authorization, API5:2023 Broken Function Level Authorization, & API8:2023 Security Misconfiguration (owasp.org/API-Security/2023).
- MITRE CWE-306: Missing Authentication for Critical Function (cwe.mitre.org/data/definitions/306.html).
- MITRE CWE-20: Improper Input Validation (cwe.mitre.org/data/definitions/20.html).
- MITRE CWE-400: Uncontrolled Resource Consumption (cwe.mitre.org/data/definitions/400.html).
- MITRE CWE-942: Permissive Cross-domain Policy with Untrusted Domains (cwe.mitre.org/data/definitions/942.html).
- MITRE CWE-693: Protection Mechanism Failure / Missing HTTP Security Headers (cwe.mitre.org/data/definitions/693.html).
- MITRE CWE-200: Exposure of Sensitive Information to an Unauthorized Actor (cwe.mitre.org/data/definitions/200.html).
- MITRE CWE-1275: Sensitive Cookie with Improper SameSite Attribute (cwe.mitre.org/data/definitions/1275.html).
- Cloudflare Bot Management Cookies Reference (
__cf_bm): Cloudflare Fundamentals — Default Cookies (developers.cloudflare.com/fundamentals/.../cloudflare-cookies). - National Research Council (NRC): Nutrient Requirements of Beef Cattle (8th Rev. Ed., National Academies Press) & Nutrient Requirements of Dairy Cattle — Reference Dry Matter (DM%) feed composition tables and physiological live-weight ranges.
- FIRST CVSS v3.1 Specification: Common Vulnerability Scoring System v3.1 (first.org/cvss/v3.1).