Knowledgebase

Preventing Cross-Site Scripting Print

  • phplaravel, database, security, guide, howto, solution, zillionkinghost, hosting
  • 0

Content interpreted as code.

WHAT IT IS

Submitted content displayed in a page and executed by the browser.

WHAT IT ALLOWS

Stealing sessions Acting as the visitor Modifying what people see

WHAT CAUSES IT

Outputting user-supplied content without escaping.

WHAT PREVENTS IT

Escaping everything displayed, according to where it appears.

WHAT FRAMEWORKS DO

Escape by default in templates.

WHAT TO CHECK

Where you have deliberately disabled that Content inserted by scripts Values placed into attributes and URLs

WHAT REQUIRES DIFFERENT TREATMENT

Content in markup Content in an attribute Content in a URL Content inside a script

Each needs its own escaping.

WHAT TO DO ABOUT USER-SUBMITTED FORMATTED CONTENT

Sanitise it with an established library, permitting only safe elements.

Never write your own filter.

WHAT ELSE HELPS

A content security policy, limiting what can execute.

WHAT NOT TO TRUST

Anything from a database, which was once input.

WHAT TO TEST

Submitting markup in every field and seeing whether it renders.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot