Input Sanitization

Input sanitization is a cybersecurity measure of checking, cleaning, and filtering data inputs from users, APIs, and web services of any unwanted characters and strings to prevent the injection of harmful codes into the system.

Hackers use remote file inclusion (RFI) and injection attacks such as SQL injection (SQLi) and cross-site scripting (XSS) to exploit the gap in the interaction between the website and the server. They can encode special characters and execute unauthorized actions that compromise security. With input sanitization in place, these types of attacks can be prevented.

An application receives queries and requests from untrusted sources that might expose the system to malicious attacks. Input sanitization ensures that the entered data conforms to subsystem and security requirements, eliminating unnecessary characters that can pose potential harm.

Sanitizing inputs

From the user s browser, data input travels through GET request, POST request, and cookies, which hackers can edit, modify, and manipulate to gain access to the web server. Input sanitization serves as a strainer to filter encoded data as it moves into the web server. This can be done in three ways:

  • Whitelist sanitizing allows only valid characters and code strings.
  • Blacklist sanitizing cleans the input by removing unwelcomed characters such as line breaks, extra white spaces, tabs, &, and tags.
  • Escape sanitizing rejects invalid data requests and strips inputs in order not to be seen as codes.

Benefits of input sanitization

Input sanitization is by no means a perfect means to ward off injection attacks and pernicious infiltration of a web server. But it has some advantages such as:

  • Providing a perimeter defense against common cyberattacks
  • Preventing some forms of remote file inclusion and injection attacks (Code injection, SQLi, and XSS)
  • Protecting the system from malicious code intrusions
  • Keeping the integrity of the web server, database, and other digital assets

Webopedia Staff
Since 1995, more than 100 tech experts and researchers have kept Webopedia’s definitions, articles, and study guides up to date. For more information on current editorial staff, please visit our About page.

Top Articles

The Complete List of 1500+ Common Text Abbreviations & Acronyms

Text Abbreviations reviewed by Web Webster   From A3 to ZZZ we list 1,559 SMS, online chat, and text abbreviations to help you translate and understand...

Windows Operating System History & Versions

The Windows operating system (Windows OS) refers to a family of operating systems developed by Microsoft Corporation. We look at the history of Windows...

How to Create a Website Shortcut on Your Desktop

Website Shortcut on Your Desktop reviewed by Web Webster   This Webopedia guide will show you how to create a website shortcut on your desktop using...

Generations of Computers (1st to 5th)

Reviewed by Web Webster Learn about each of the 5 generations of computers and major technology developments that have led to the computing devices that...

How to Find Your...

SSID is short for Service Set IDentifier. In layman’s terms, an...

Monday.com

Monday.com is a cloud-based work operating system that can be used for a...

Secure Socket Tunneling Protocol...

The secure socket tunneling protocol (SSTP) is a VPN protocol where...