Source: TesterHome Community

SQL injection attacks occur when developers fail to perform strict security checks on parameters transmitted from the client to the server. When an SQL statement uses such parameters and executes via string concatenation, attackers can insert malicious SQL query statements into the parameters, forcing the server to execute them.
Potential harms
On pages that require queries, input a correct query condition followed by simple SQL statements like and 1=1. Observe the response. If the returned result remains consistent with the result from the correct query condition alone, the application likely does not filter user input — suggesting a possible SQL injection vulnerability.
JDBC Queries. Use PreparedStatement. This improves query efficiency, and its set methods handle SQL injection issues automatically.
Hibernate Queries. Use named parameters (e.g., name:parameter) or methods like find(String queryString, Object value...) to avoid SQL injection.
Input Validation. Inspect SQL within query methods. Convert or filter out illegal characters that could be used for SQL injection.
Client-Side Restrictions. Use JavaScript on pages to prevent users from entering illegal characters. (Note: This serves user experience, not primary security control.)
Global Request Filter (Without Attachments). Implement a filter class inheriting HttpServletRequestWrapper and configure it in web.xml to intercept each request parameter and convert illegal characters.
Global Request Filter (With Attachments). Configure a class inheriting CommonsMultipartResolver for file uploads to process parameters.
Security Software. Deploy server and web application firewalls (e.g., “SafeDog”), and consider professional cloud security services.
CSRF is a network attack where a malicious website tricks a user’s browser into executing unwanted actions on a trusted site where the user is authenticated — all without the user’s knowledge. Essentially, the attacker steals the user’s identity to send malicious requests that appear completely legitimate to the server.
Attack mechanism and process
Referer Validation. Website A validates the Referer header for every request. If the Referer comes from A’s own domain, the request is likely legitimate. If it comes from another domain, it might be a CSRF attack and should be rejected. However, the Referer value is provided by the browser and can be spoofed or missing.
Token Validation. Add a unique, unpredictable token (e.g., synchronizer token) to each request and validate it on the server side. This is the most common and effective defense.
XSS occurs when a web application includes unvalidated or unescaped user input in its output pages, allowing attackers to inject malicious HTML or JavaScript code. This code executes in the context of another user’s browser. Unlike SQL injection (which targets the server), XSS targets other users of the application.
Potential impacts
Stored (Persistent) XSS. Malicious script permanently stored on the server (e.g., in a database). Victims execute it when requesting stored information. Example: An attacker posts a comment containing malicious script. The server stores it. Every user viewing the comment executes the script.
Reflected (Non-Persistent) XSS. Malicious script reflected off the web server via a crafted link or form submission. The victim’s browser executes it when clicking the link. Example: A hacker posts a malicious link on a message board. The victim clicks it, sending the malicious script to the server, which reflects it back and executes it, sending the victim’s cookie to the hacker.
DOM-based XSS. The vulnerability exists in client-side JavaScript that processes user-controlled input unsafely (e.g., document.write, eval), altering the DOM maliciously.
The core principle is to treat all user-provided content as unsafe. Filter or escape malicious code appropriately based on the output context (HTML attribute, JavaScript, CSS, etc.). Using a well-vetted library is highly recommended. For example, in Node.js projects, use the xss library.
This vulnerability — also known as unvalidated redirects and forwards — occurs when a web application redirects users to a URL provided via untrusted input (e.g., a request parameter) without proper validation. Attackers can exploit this to redirect users from a legitimate trusted site to a malicious third-party site for phishing or other attacks.
Note: Many modern applications use Referer validation or other checks, making simple bypasses ineffective.
Server-side mapping (best). If the destination URL is known beforehand, use an identifier (index) mapping to a pre-configured URL on the server.
Sign the redirect URL. If the URL is generated server-side, create a signature (e.g., HMAC) and validate it before performing the redirect.
Whitelist validation. If the URL must come from user input, strictly validate it against an approved list of domains or a safe URL pattern.
Input sanitization. Check for and remove control characters (e.g., URL-encoded for CRLF injection) from the redirect parameter.
Update dependencies. Keep all frameworks and libraries (e.g., Django, Nacos, Log4j2, nginx) up-to-date with the latest security patches.
This critical vulnerability allows an attacker to upload a malicious executable file (e.g., Trojan, virus, script, WebShell) to the server. If the file can be executed or accessed, the attacker can gain control of the web server or application.
Potential harms
Client-side (JS) detection. Uses JavaScript to check file extension before upload. This is trivially bypassed (disable JS or intercept requests) and is not secure.
Server-side detection. Validates the file after receipt using MIME type, extension, and file content or magic bytes. This is reliable.
Blacklist. Denies specific file types (e.g., .php, .exe). Easy to bypass and weak.
Whitelist. Allows only specified types (e.g., .jpg, .png). This is the strongest approach.
Bypassing client-side (JS) detection. Disable JavaScript in the browser, or use a proxy like Burp Suite to intercept the request and change the filename. Example: Change filename from malicious.jpg (to pass JS check) to malicious.php in the intercepted HTTP request.
Bypassing server-side MIME type detection. Intercept the request and modify the Content-Type header (e.g., from application/x-php to image/jpeg).
Bypassing extension detection.