Scalable and under control open cloud architecture considering security standards. Leszek Miś IT Security Architect RHCA,RHCSS,Sec+ lm@linuxpolska.pl Linux Polska Sp. z o.o. 1
#whoami 2 Leszek Miś: IT Security Architect RHCA/RHCSS/Sec+ Instruktor/egzaminator Red Hat Splunk Certified Architect Lider projektu WALLF Web Gateway Skupiam się głównie na: Linux/Web/Cloud Security SELinux/WAF/SSO IdM/Domena ilnuksow Pentesty
O firmie Linux Polska 3 Podstawowa działalność spółki: Wsparcie lokalne dla systemów Open Source Wdrożenia i migracje Bezpieczeństwo IT Szkolenia autoryzowane i autorskie
Agenda 4 Web (in)security OWASP Infrastructure as code Secure reverse Proxy
Web (in)security 5 Aplikacje webowe jako cel czyli zagrożenia kryją się wszędzie: Aplikacja Protokół Implementacja HTTP Język/Framework Konfiguracja System operacyjny
Web (in)security Rzeczywistość weryfikuje: Zimbra: priv_esc poprzez LFI: 6 /res/i18nmsg,ajxmsg,zmsg,zmmsg,ajxkeys,zmkeys,zdmsg,ajx%20templatemsg.js.zgz? v=091214175450&skin=../../../../../../../../../opt/zimbra/conf/localconfig.xml OSSIM: SQL Injection Apache Struts: RCE F5 BigIQ priv_esc JIRA: directory traversal Katello: users/update_roles I wiele, wiele innych...
Web (in)security 7 Problem z patchowaniem podatności: Wysoki koszt Kod źródłowy firmy zewnętrznej Ograniczony kontrakt/umowa Brak zasobów Brak skillsów SDLC -> TST->ACC->PROD Niedostępność aplikacji Inne?
Web (in)security 8 Cross Site Scripting ClickJacking SQL Injection MitB LDAP Injection Open Redirect XPATH Injection DOS/DDOS XML Injection Cross Site Request Forgery (CSRF) Blind SQLi Information/Path Dislosure Time based SQLi Encoding Remote Command Execution Server Side Includes Injection Local File Inlusion Bruteforce Remote File Inclusion Buffer overflow Session Hijacking Misconfiguration HTTP Response Spliiting Forced browsing Sniffing/Spoofing Drive by Download
OWASP 11
OWASP Open Web Application Security Project Misja: Poprawa stanu bezpieczeństwa aplikacji Make application security visible so that people and organizations can make informed decisions about true application security risk Projekty dokumentacja, narzędzia Edukacja Współpraca (rządy, inne organizacje, twórcy standardów) 12
Wybrane projekty OWASP DETECT PROTECT LIFE-CYCLE Documentation Top10 ASVS Testing Guide Code Review Guide Development Guide OpenSAMM Secure Coding Practices Quick Reference Tools WebScarab ESAPI WebGoat Zed Attack Proxy AppSensor Education Project JBroFuzz ModSecurity Core Ruleset https://www.owasp.org/index.php/category:owasp_project 13
OWASP Top 10 14 Zbiór 10 najistotniejszych, kluczowych błędów w zabezpieczeniach aplikacji internetowych: A1 Injection A2 Broken Auth and Session MGMT A3 XSS A4 Insecure Direct Object References A5 Security Misconfiguration A6 Sensitive Data Exposure A7 Missing Function Level Access Control A8 CSRF A9 Known vulns A10 Unvalidated Redirects and Forwards
OWASP ASVS Security Verification Standard Testing guide księga testów Appsensor WAF wszyty w appkę ESAPI Enterprise Security API Broken Web Application poligon 15
Infrastructure as code 16
Infrastructure as code 17 Problem dt. spójności infrastruktury: Na których systemach zmiana została wprowadzona? Czy pojawiła się na wszystkich systemach? Czy została zaaplikowana tylko na tych systemach na których było to niezbędne? Co z systemami, które w tym czasie były niedostępne? Co z nowymi systemami, które dodamy do naszej infrastruktury?
Infrastructure as code Zgodność ze standardami Powtarzalność: Weryfikacja: 18 enforcing Współdzielenie: kontrola wersji Gwarancja poprawności: skalowalność TST->ACC->PROD Aktualność konfiguracji: ready for audit
Infrastructure as code 19
Infrastructure as code 20 Abstrakcja-> Oczekiwany status: SSL Cipher list Error handling/output filtering Antibrute force mechanism Secure flags for cookies STIG compliance
Infrastructure as code <% if @mod_security -%> SecRuleEngine <%= @mod_security %> <% end -%> vhost.conf.erb: <%= scope.function_template(['wallf/apache/_secureheaders.er b']) -%> 21
Infrastructure as code 22 Antibrute force
Infrastructure as code 23 SSL
Infrastructure as code 24 SSL: Sslscan ssllabs
Infrastructure as code 25 Error Handling modsecurity_crs_50_outbound.conf
Infrastructure as code 26 Header manipulation: unset X-Powered-By unset Server set X-XSS-Protection: "1; mode=block"' set Header always set X-Frame-Options SAMEORIGIN
Infrastructure as code 27 Secure cookies: HttpOnly Secure Path=
Secure Web Gateway -> Open Source <- OWASP 29
Secure Web Gateway - co jest istotne? Hardened Linux distro Isolation HA Separation LB/Clustering Scalability WAF Monitoring SSL configuration Caching Access Control Performance tuning Change Mgmt 2FA Logging Mgmt Auditing Incident Response Mgmt 30
WAF 31 Architektura
WAF Fazy filtrowania: Każda transakcja przechodzi przez 5 faz filtrowania: 32 1: Request headers 2: Request body 3: Response headers 4: Response body 5: Logging
WAF Ochrona przed atakami i integracja z DAST (Arachni,ZAP) Filtrowanie żądań 0-day protection 34 Dynamiczne wstrzykiwanie - modyfikacja danych wychodzących w locie Wirtualne patchowanie
WAF 35 Wirtualny patch w uproszczonym przypadku: Ograniczenie Request_Body_Size Wykrywanie powtarzających się payloadów Ograniczenie ilości ARGS Weryfikacja/filtrowanie wartości ARGS Analiza i filtrowanie RESPONSE_BODY
WAF tryby pracy Negative security model: SecRule REQUEST_FILENAME @contains /owa/scriptname.asx chain, phase:1,block,log,msg:'xss na mojej appce' SecRule ARGS:parameter @pm < > ( ) -- Positive security model: SecRule REQUEST_FILENAME @contains /owa/scriptname.asx chain, phase:1,block,log,msg:'xss na mojej appce' SecRule ARGS:parameter!@rx ^\w+$ 36
WAF 37 Przykładowe reguły: SecRule REQUEST_URI "@detectsqli" "id:152,log,deny" SecRule REQUEST_BODY "@detectxss" "id:12345,log,deny" SecRule REQUEST_HEADERS:User-Agent "@pm WebZIP WebCopier Webster WebStripper... SiteSnagger CheeseBot" "id:166" SecRule ARGS:foo "!@streq bar" "id:176"
WAF 38 Modsecurity to tylko silnik: Apache Nginx IIS Musimy go naładować : Tworzenie dedykowanych reguł od podstaw per aplikacja Wykorzystanie gotowych reguł OWASP CRS Hybryda czyli połączenie reguł CRS z własnymi regułami typu whitelist
WAF modsecurity CRS HTTP Protection - detecting violations of the HTTP protocol and a locally defined usage policy. Real-time Blacklist Lookups - utilizes 3rd Party IP Reputation HTTP Denial of Service Protections - defense against HTTP Flooding and Slow HTTP DoS Attacks. Common Web Attacks Protection - detecting common web application security attack. Automation Detection - Detecting bots, crawlers, scanners and other surface malicious activity. Integration with AV Scanning for File Uploads - detects malicious files uploaded through the web application. Tracking Sensitive Data - Tracks Credit Card usage and blocks leakages. Trojan Protection - Detecting access to Trojans horses. Identification of Application Defects - alerts on application misconfigurations. Error Detection and Hiding - Disguising error messages sent by the server. 39
WAF 40 Reguły OWASP CRS podzielone są na: base_rules experimental_rules optional_rules slr_rules Dostosowanie reguł CRS per aplikacja: SecRuleRemoveById SecRuleRemoveByMsg SecRuleRemoveByTag (Konsola)
WAF advanced HMAC Content Security Policy Webhoneypots LUA JSON/XML AV Scanning GEO/IP reputation BEEF czyli Attack the attacker: 41 Browser as Pentester's gateway
Podsumowanie WAF = ubezpieczenie Krytyczność reverse proxy Podejście devopsowe do zarządzania bezpieczeństwem WAF_Mgmt jako element Change_Mgmt Zasoby OWASP jako wzorce do naśladowania Open source Some people, wether vemdors or customers, believe in "auto learning mode". My experiance with such systems is that the (generated) rule set becomes unmanageable after a couple of time. - Achim Hoffman - OWASP 43
Dziękuję za uwagę. Leszek Miś IT Security Architect RHCA,RHCSS,Sec+ lm@linuxpolska.pl Linux Polska Sp. z o.o. 45