HTML injection without proper validation
This lab demonstrates a basic HTML injection vulnerability where user input is directly inserted into HTML output without proper validation or encoding. The application allows injection of arbitrary HTML content that gets rendered by the browser.
Objective: Inject HTML content to manipulate the page appearance and potentially execute JavaScript.
// Vulnerable: Direct output without validation
function process_html_input($input) {
if (empty($input)) {
return "No input provided.";
}
// Vulnerable: Direct output without encoding
return $input;
}
Try these basic HTML tags:
<h1>Hello World</h1> - Heading<p style="color:red">Red Text</p> - Styled paragraph<img src="image.jpg"> - Image<script>alert('XSS')</script> - JavaScript<h1>Hello</h1> - Basic HTML<img src="x"> - Image tag<script>alert(1)</script> - JavaScript<style>body{background:red}</style> - CSSUse these payloads to test the HTML injection vulnerability:
This is a paragraph
Bold text Italic text Underlined textRed text
| Name | Age |
|---|---|
| John | 25 |