Summary
A missing authorization check in ERPNext's Stock module import endpoint can allow authenticated users to read the contents of a named file and create Serial No or Batch records. The risk exists when the endpoint accepts import requests without verifying the caller's permissions for the requested file and records.
Affected context
The issue affects ERPNext 15.0.0 before 15.121.4 and 16.x before 16.36.0. It occurs in a Stock module import endpoint where authorization checks for file downloads and inserted records are missing or insufficient. The description indicates that authenticated portal users and users with no roles may be able to reach the endpoint.
Exploit preconditions
- Attack surface: The Stock module import endpoint
- Required access: An authenticated account; the description includes portal users and users with no roles
- Trigger point: A crafted import request that names a file or requests record creation
- Why exploitation is possible: The endpoint does not adequately verify whether the caller is authorized to access the named file or create the requested records
Why this happens
The endpoint performs sensitive file access and record creation without enforcing authorization for those operations. This is a broken access control flaw mapped to CWE-862: Missing Authorization: the application fails to check whether the authenticated caller has permission to perform the requested action on the relevant resource.
Potential impact
- An attacker could read file contents that should not be available to their account.
- An attacker may be able to create unauthorized Serial No or Batch records.
- Unauthorized records could affect inventory data and related business workflows.
General mitigation guidance
Defensive patterns include enforcing server-side authorization checks for every file access and record creation operation, based on the specific resource and action requested. Prefer deny-by-default policies, minimize the permissions granted to portal and low-privilege accounts, and avoid treating authentication or possession of a file name as proof of authorization. Validate imports against explicit schemas and ensure permission checks occur before sensitive data is read or records are written.
How teams detect issues like this
Review import handlers for file reads or record creation that occur without resource-specific permission checks. Static analysis and code review can look for endpoint paths that invoke these operations without authorization guards, including checks applied only in the user interface. Policy enforcement can require server-side authorization tests for low-privilege, portal, and role-less accounts. Monitor import activity for unexpected file access and record creation by accounts with limited permissions.

