SQL Injection
ความรุนแรงระดับวิกฤต
1SQL Injection คืออะไร?
SQL Injection is one of the most dangerous web vulnerabilities. Attackers insert malicious SQL commands into your application's input fields to manipulate your database. This can lead to unauthorized access, data theft, or complete database destruction.
2สคริปต์การแทรกแซงและตัวอย่างการโจมตี
-- Login Form Attack Username: admin' -- Password: anything -- What Actually Happens: SELECT * FROM users WHERE username='admin'--' AND password='anything' -- The -- comments out the password check! -- Advanced: Extract All Data Username: ' UNION SELECT username, password FROM users-- -- This adds a second query to dump all usernames and passwords
3วิธีป้องกันการโจมตีนี้
Use parameterized queries (prepared statements)
Validate and sanitize all user inputs
Use ORM frameworks
Apply principle of least privilege to database accounts