Skip to main content

Stored cross-site scripting (XSS)

Description

It is possible to persistently inject JavaScript code into the application fields. This could allow an attacker to compromise the session of any user who enters the platform or to distribute malicious software.

Impact

Inject malicious JavaScript code persistently.

Recommendation

Filter the information that receives and sends the application using white lists.

Threat

Authorized attacker from the Internet.

Expected Remediation Time

⌚ 45 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: R
  • Scope: C
  • Confidentiality: L
  • Integrity: L
  • Availability: N

Temporal

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

Result

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

Code Examples

Compliant code

The application defines parameters and limitations for input information.

class ContactController {
/**
* @input("name", type = "string", singleLine = true, required = false)
* @input("email", type = "email")
* @input("subject", type = "string", alternatives = ['Subject A', 'Subject B', 'Subject C'])
* @input("message", type = "string", range = [4,])
*/
public function post(Inputs $inputs){
//Validates inputs and throw error when they are not included in the allowed and pre defined lists values
}
}

class ContactForm extends sfFormX {
public function configure(InputsMeta $inputs){
//Bind the form to the input list of the @[email protected]
//throws error when the @[email protected]@input is not defined for a widget
$this->addWidgets(
new sfWidgetFormInput($inputs->name),
new sfWidgetFormInput($inputs->email),
new sfWidgetFormSelect($inputs->subject),
new sfWidgetFormTextarea($inputs->message)
);
$this->widgetSchema->setNameFormat('contact[%s]');
}
}

Non compliant code

There are some clases in the applicatin that do not have any validation for the inputs

class ContactForm{
public function configure(InputsMeta $inputs){
addWidgets(
new sfWidgetFormInput($inputs->name),
new sfWidgetFormInput($inputs->email),
new sfWidgetFormSelect($inputs->subject),
new sfWidgetFormTextarea($inputs->message)
);
}
}

Requirements