What is SQL Injection
❗SQL Injection is a specific category of cyber attacks. It is a dangerous way of exploiting data inputs on a website database. This may cause a security breach whereby data can be stolen, destroyed, or the site itself hacked.
❗SQL Injection takes place when a hacker enters malicious SQL code into an uncleaned website’s input fields. Input is sent to the database of the website which treats the action as valid and provides the attacker with an opportunity of gaining sensitive data or control of the system.
💡 Here's a simple example
Suppose there is an e-commerce site that requires authentication upon entry. The website goes through the database when you enter the username and password to confirm if you are an authenticated user. If the site doesn't properly validate the input, an attacker can enter something like:
💻 [ ' OR '1'='1 ]
💡 The system takes this as a valid input, and injected code always evaluates to 'true' ('1' = '1'). The attacker gains unauthorized access.
📝 SQL injection is dangerous, though with proper prevention, your website and data can still remain safe to access with ease. Ensure that you always maintain a high level of security when coding to avoid such attacks.
📌 In the next post, we'll discuss how to prevent SQL Injection.
![post image](https://clubs-uploads.internshala.com/post/images/c14948c1bb66b565dcdda4ed1638e324.png)
18 likes