Input sanitization is an important aspect of secure coding to prevent various forms of attacks, such as SQL injection, Cross-Site Scripting (XSS), and command injection. While the specific set of characters to block may vary depending on the context and the technology stack you’re using, here is a general list of special characters and character sequences that you should consider blocking or escaping:
Note: Please note that the list below is not exhaustive, and the characters to block or sanitize may vary depending on the specific programming language, framework, application’s requirement, or context in which you are working.
` ' " ; \ \x00 %00 < > & / \ | $ ( ) { } ! : % ? # @ [ ] * . + ^ \r \n %0A %0D
Vulnerability Name | Special Characters |
SQL Injection |
|
Cross-Site Scripting (XSS) |
|
Command Injection |
|
File Inclusion/Path Traversal |
|
LDAP Injection |
|
XML Injection |
|
Server Side Template |
|
Open URL Redirection |
|
Server-Side Request Forgery (SSRF) |
|
CRLF Injection |
|
CSV Injection |
|
Whitespace and Control Characters |
|