Prevent SQL Injection with iptables

Hi Experts.

I'm setting up iptables for a system so I want to ask if there is any rule/module that can prevent SQL Injection on iptables.

Thanks for reading this.
LVL 2
ldvhaiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arnoldCommented:
Usually iptables has to use snort or something like that to detect signatures.

to prevent SQL injection, your code is a far better mechanism to address that.

i.e. make sure you are not passing form data directly to the sql server.

Check if there are articles on this issue at EE.
0
btanExec ConsultantCommented:
You may be interested in this test out stated in paper2-ICMSC2011S008.pdf
after combining the rules, number
of the rules to be put into IPTABLES conclusively became 9 as presented below.
 
iptables -I FORWARD -s 0.0.0.0/0 -m string --string “%27+or+%271%27%3d%271” --algo bm -j DROP

iptables -I FORWARD -s 0.0.0.0/0 -m string --string “%27+or+1%3d1” --algo bm -j DROP

iptables -I FORWARD -s 0.0.0.0/0 -m string --string “%27+or+%271%27%3d%271” --algo bm -j DROP

iptables -I FORWARD -s 0.0.0.0/0 -m string --string “%27)+or+%27%27%3d%27” --algo bm -j DROP

iptables -I FORWARD -s 0.0.0.0/0 -m string --string “%27)+or+1%3d1” --algo bm -j DROP

iptables -I FORWARD -s 0.0.0.0/0 -m string --string “%27)+or+%271%27%3d%271” --algo bm -j DROP

iptables -I FORWARD -s 0.0.0.0/0 -m string --string “%27)+or+(%27%27%3d%27” --algo bm -j DROP

iptables -I FORWARD -s 0.0.0.0/0 -m string --string “%27)+or+(1%3d1” --algo bm -j DROP

iptables -I FORWARD -s 0.0.0.0/0 -m string --string “%27)+or+(%271%27%3d%271” --algo bm -j DROP

These mentioned rules were able to protect the websites from all of 23 SQL Injection Attacks listed on
the website: http://www.governmentsecurity.org. In conclusion, when excluding new forms of web attack, it could be resolved that the protection system, designed by the researchers’ team, was able to effectively
protect the website from SQL Injection Attack.
The “%27or%271%27%3D%271” was an encoding. When decoding the URL, it would result as a
message ' or '1'='1.

The abovementioned rule was able to block SQL Injection Attack by detecting the strings (packet) that matched the security requirement. When the packet that matched the defined string was found,
that packet would be immediately dropout.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
arnoldCommented:
The above deals with aURL encoded (GET request)
A post request could still go through.

Best to safeguard your system, is to make sure the code in use is not suseptible to SQL injection.
0
btanExec ConsultantCommented:
agree secure coding and OWASP has good reference on it. Build different layer of defence starting from the code level into the web appl, and to the host OS (host defence like iptables), into web server (with WAF like mod sec) and at the network perimeter facing external network with WAF as it is app aware type of FW - not only SQLi but also others mentioned in OWASP like XSS etc.
0
ldvhaiAuthor Commented:
Thank you for the instructions above, i'm really appreciate it.

Sincerely.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Vulnerabilities

From novice to tech pro — start learning today.