Skip to main content

Insecure object reference - Files

Description

An unauthorized user can access or manipulate information of other users just by knowing the identifier that differentiates them, since the application does not validate the necessary permissions to access.

Impact

Access or manipulate the victims account information by knowing a victims user ID.

Recommendation

Verify that the user who is trying to access the information has the necessary permissions to access.

Threat

Unauthorized user from local network.

Expected Remediation Time

⌚ 30 minutes.

Score

Default score using CVSS 3.1. It may change depending on the context of the vulnerability.

Base

  • Attack vector: N
  • Attack complexity: L
  • Privileges required: L
  • User interaction: N
  • Scope: U
  • Confidentiality: N
  • Integrity: L
  • Availability: N

Temporal

  • Exploit code madurity: X
  • Remediation level: O
  • Report confidence: X

Result

  • Vector string: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N/E:X/RL:O/RC:X
  • Score:
    • Base: 4.3
    • Temporal: 4.1
  • Severity:
    • Base: Medium
    • Temporal: Medium

Code Examples

Compliant code

The application verifies user credentials before accessing sensitive information

const accessfile = (req, res) => {
if (isValidUser(req.body.user)) {
const file = req.body.File;
if FilesModel.find(file.id){
const isAccessgranted = verifyUserAccess(file, req.body.id)
if isAccessgranted{
//Code that allows access to the user to edit the File only if the user has access
}
}
}
}

Non compliant code

The application only checks userId before allowing access to sensitive information

const accessFile = (req, res) => {
if (isValidUser(req.body.user)) {
const File = req.body.file;
//Accessing File only with the id number
if filesModel.find(File.id){
//Code that allows access to the user to access the File
}
}
}

Requirements