Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
ModSecurity 2.5

You're reading from  ModSecurity 2.5

Product type Book
Published in Nov 2009
Publisher Packt
ISBN-13 9781847194749
Pages 280 pages
Edition 1st Edition
Languages

Table of Contents (17) Chapters

ModSecurity 2.5
Credits
About the Author
About the Reviewers
1. Preface
1. Installation and Configuration 2. Writing Rules 3. Performance 4. Audit Logging 5. Virtual Patching 6. Blocking Common Attacks 7. Chroot Jails 8. REMO 9. Protecting a Web Application Directives and Variables Regular Expressions Index

Blocking what's allowed—denying everything else


So how do we actually implement the positive security model where that which we explicitly allow can pass through and everything else is blocked? Say for example that an argument named foo must have a value of bar, and that any other value for foo should be blocked. One approach would be the following:

SecRule ARGS:foo "!^bar$" "deny"

This works fine and will block any value for foo other than bar. It will even work in cases where foo isn't specified in the query string, since the rule will not be evaluated if the foo argument isn't present. However, what if someone decided to provide an argument named fox in the query string, just to see what would happen? According to our security model, we should block any argument that isn't explicitly whitelisted, so the presence of an argument named fox should lead to a denied request. It's clear that we need to add another check to make sure that only whitelisted argument names are allowed through.

The...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}