/

CVE-2026-30576

Severity:

HIGH RISK

(7.5)

Business Logic / Input Validation in Pharmacy Product

CVE-2026-30576

Analyzed

Vulnerability type

Category:

Business Logic / Input Validation

CWE:

CWE-20

Impact:

Financial Data Integrity Compromise

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A business logic input validation flaw in SourceCodester Pharmacy Product Management System 1.0 allows negative values to be submitted for price and total cost when adding stock.

By abusing the txtprice and txttotalcost parameters in add-stock.php, an attacker can corrupt financial records and manipulate inventory asset values and procurement costs under normal application use flows.

Affected context

The vulnerability occurs in the stock entry workflow of the Pharmacy Product Management System, specifically in add-stock.php when users add or update inventory.

It affects deployments where user-supplied financial fields such as txtprice and txttotalcost are trusted without enforcing domain-specific constraints (e.g., non-negative values, reasonable ranges).

The issue is most relevant in environments where staff, partners, or integrated systems can submit stock entries and where those entries feed into accounting, reporting, or inventory valuation processes.

Exploit preconditions

  • Attack surface: Web application stock management interface (add-stock.php).
  • Required access: Ability to submit stock entry forms (typically authenticated user or anyone with access to the inventory management feature).
  • Trigger point: Submission of stock records with negative values for txtprice and/or txttotalcost.
  • Why exploitation is possible: The application performs minimal or no server-side validation of these fields and does not enforce logical business rules (such as non-negative prices and costs), allowing crafted values to be accepted and stored.

Why this happens

The root cause is inadequate input validation for business-critical numeric fields, mapping to CWE-20: Improper Input Validation.

While the application may syntactically accept numeric input, it fails to apply semantic constraints that reflect real-world business rules (e.g., prices and total costs should not be negative).

This lack of domain validation lets users submit values that are mathematically valid but logically impossible, leading to inconsistent financial records and exploitable discrepancies in accounting and inventory valuation logic.

Potential impact

  • Manipulation of inventory asset values to appear lower or negative.
  • Artificial reduction or inflation of procurement costs in financial reports.
  • Corruption of accounting data, including profit/loss calculations and stock valuation.
  • Potential facilitation of fraud or concealment of unauthorized stock movements.
  • Disruption of downstream processes that rely on accurate financial and inventory data.

General mitigation guidance

Effective mitigation focuses on enforcing business rules at the server side and treating all client input as untrusted:

  • Apply strict domain validation for financial fields, ensuring they are non-negative and within reasonable bounds.
  • Enforce business constraints in centralized validation layers, not just in client-side scripts or UI controls.
  • Normalize and validate all numeric inputs using server-side checks before persisting or using them in calculations.
  • Implement integrity safeguards around financial and inventory operations, such as invariants (e.g., total cost = quantity × unit price and all terms non-negative).
  • Use least-privilege design for user roles so that only appropriate staff can perform sensitive stock and pricing operations, reducing abuse risk.

How teams detect issues like this

Organizations can detect this kind of vulnerability using both code-centric and behavior-centric approaches:

  • Static analysis / code review: Search for financial or quantity fields that are cast to numeric types and stored without range or sign checks; flag direct use of request parameters in database writes or calculations without validation.
  • Business logic reviews: Perform manual walkthroughs of critical workflows (stock entry, pricing, invoicing) to confirm that business rules are explicitly enforced on the server.
  • Logging and anomaly detection: Monitor inventory and financial records for anomalous negative values or out-of-range prices and costs, and generate alerts for review.
  • Testing and QA: Incorporate domain-specific test cases in automated and manual testing to verify that invalid business values (e.g., negative prices) are consistently rejected.

Sources

SourceLink
github.comgithub.com/meifukun/Web-Security-PoCs/blob/main/Pharmacy-Product-Management-System/Logic-AddStock-NegativePrice.md

Frequently asked

questions

Yes, it can be exploited over the web interface wherever the stock entry functionality is exposed. However, it typically requires access to a valid workflow (such as a logged-in user with stock management permissions).

The attacker needs the ability to submit or modify stock entries through the application. This is often available to staff accounts or any role permitted to manage inventory, but exact access depends on how roles and permissions are configured.

Implement strict server-side domain validation for all financial and inventory-related fields, ensuring they cannot be negative or otherwise violate business rules, and centralize these checks so they are consistently applied across all entry points.

Incorporate business logic reviews into the development lifecycle, define explicit invariants for financial and inventory data, enforce them in server-side validation layers, and include domain-specific negative and boundary test cases in automated tests and security reviews.

Find out what's already
exploitable in your codebase.