Skip to main content

Lack of data validation - Modify DOM Elements

Description

The application allows the creation of dynamic DOM (Document Object Model) elements from user controlled inputs. In addition to being functionally expensive, this operation can lead to the creation and exploitation of other vulnerabilities such as buffer overflow or memory corruption.

Impact

Cause unexpected behaviours in the application which can lead to system unavailability.

Recommendation

Avoid generating dynamic DOM from user controlled inputs

Threat

Authenticated attacker from the Internet

Expected Remediation Time

⌚ 120 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: P
  • Remediation level: O
  • Report confidence: C

Result

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

Code Examples

Compliant code

The application uses user input only after validating its contents

function DOMCreation(request *http.Request) {
userOutput = validateString(request.content);
const para = document.createElement("p");
para.innerText = userOutput;
document.body.appendChild(para);
}

Non compliant code

The application uses user input without server side validation

function ErroneousDOMCreation(request *http.Request) {
element = document.createElement(request.content);
document.body.appendChild(element);
}

Requirements