Summary
metasfresh exposes document attachment and comment endpoints that verify authentication but do not consistently enforce record-level authorization. An authenticated attacker may enumerate sequential document identifiers to read, replace, or delete content associated with records outside their permitted role or scope.
Affected context
The vulnerability occurs in deployments where the metasfresh DocumentAttachmentsRestController or CommentsRestController can be reached by an authenticated user, while authorization checks stop at verifying that the caller is logged in. It becomes risky when document identifiers are predictable or discoverable and endpoint handlers do not independently confirm that the caller may access the referenced record.
Exploit preconditions
- Attack surface: Authenticated document attachment and comment REST endpoints
- Required access: A valid user account or session accepted by the application
- Trigger point: Requests referencing document identifiers through attachment or comment operations
- Why exploitation is possible: Sequential or otherwise predictable identifiers may be used to address records without an effective record-level permission check
Why this happens
The underlying bug is an authorization design failure in which authentication is treated as sufficient authorization for object-specific operations. Endpoint handlers accept a caller's reference to a document, attachment, or comment without verifying that the caller has permission to access or modify that specific object. This behavior maps to CWE-639: Authorization Bypass Through User-Controlled Key, commonly associated with insecure direct object references.
Potential impact
- Attackers may read attachments or comments from unauthorized records
- Attackers could replace legitimate attachments or comments
- Attackers could delete business content or audit-relevant discussion
- Sensitive operational, customer, or document data may be disclosed
- Data integrity and workflow decisions could be affected
General mitigation guidance
Mitigation generally focuses on enforcing authorization at the object and operation level rather than relying only on authentication.
Common defensive patterns include:
- Apply centralized, server-side record-level authorization for every read, create, replace, and delete operation
- Derive the permitted record scope from the authenticated principal and trusted server-side context
- Avoid treating client-supplied identifiers as proof of access
- Use deny-by-default authorization policies and least-privilege roles
- Return consistent responses that do not unnecessarily reveal whether unauthorized identifiers exist
- Consider non-sequential or opaque identifiers as defense in depth, not as a replacement for authorization
- Add authorization checks to shared service-layer methods so alternate endpoints cannot bypass them
How teams detect issues like this
Organizations can identify this class of issue through:
- Static analysis and policy checks for controller methods that load objects directly from request parameters
- Code review searches for authentication checks without corresponding ownership, tenant, role, or record-permission checks
- Tests that access valid object identifiers across users, roles, and organizational boundaries
- API authorization testing covering read, update, replacement, and deletion operations
- Monitoring for sequential identifier access patterns, repeated authorization failures, and unusual bulk retrieval or deletion activity
- Automated security review tools that flag direct object lookup paths lacking an authorization decision

