Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How Your Laravel Application Can Get Hacked, And How to Prevent That From Happening?

How Your Laravel Application Can Get Hacked, And How to Prevent That From Happening?

In this talk I go through 4 common development flaws and mistakes that can lead your Laravel application being compromised in production.

The actual hands-on demonstrations aren't _really_ visible from the slides, they can be seen from the recording of this talk published in Youtube later.

Antti Rössi

May 23, 2019
Tweet

More Decks by Antti Rössi

Other Decks in Technology

Transcript

  1. How your Laravel application can get hacked, and how to

    prevent that from happening? Antti Rössi, Laracon EU - Madrid 2019
  2. # whoami Helsinki, Finland CTO @ Jobilla Oy During daytime

    I build a digital software product. During night-time I hack software in order to make it more secure. (CTFs, pentesting, bug bounties) #pystyyvetää
  3. !! Disclaimer !! All material and examples in this talk

    are for educational use only. The term ‘hacking’ in this presentation refers to ‘ethical hacking’ and should not be confused with ‘black hat hacking’, meaning attacking or attempting to attack any application, systems or network unauthorized. Hacking or attempting to hack anything you don’t own is by default illegal. Doing so will eventually get you in jail. Please act responsibly. I as the author is this presentation, nor any author of the tools used in this presentation shall not be responsible for any individual performing illegal actions with the tools or methods used in this presentation. The intent of this presentation and of all the demonstrations involved, is to help professional software developers to write more secure software.
  4. Your application is as secure as its weakest link. Take

    in account all dependencies and the whole supply chain of every single component.
  5. All of the following attacks exploit vulnerabilities caused by an

    engineering flaw by either the developers, or the admins of the example application. NOT BY LARAVEL FRAMEWORK
  6. XSS Attack Attacker executes a malicious script in the victims

    browser. Usually targets sensitive information like authentication tokens.
  7. {{-- Echoing unescaped content into a blade template exposes a

    XSS vulnerability --}} <span>Title: {!! $msg!"title !!}</span> <span>Message: {!! $msg!"body !!}</span>
  8. SQL Injection Attacker injects malicious SQL queries into eg. an

    HTTP request. Can lead to a full disclosure of the DB content when successful.
  9. Malicious File Uploads Improperly validated file uploads can allow an

    attacker to upload & run malicious scripts on the target machine.
  10. Malicious File Uploads Around half of the tutorials I found

    for ‘How to Upload Files with Laravel’ online don’t mention filetype validation at all…
  11. Privilege Escalation Exploiting a bug, design flaw, or configuration flaw

    to access resources that would otherwise require higher privileges than what’s currently available.
  12. Tip #1 Do not trust user input of any format.

    Validate everything, sanitise everything.
  13. Tip #3 Do not run code that you don’t understand

    in production. Eg. copy-pasting code from online tutorials.
  14. Tip #4 Follow the principle of least privilege. Both in

    your application, and on your production host.
  15. Tip #5 Automate everything that’s reasonably possible. This reduces the

    chance of human error, and makes your environments & configs easier to audit.
  16. Tip #6 Don’t leave utilities that you don’t need on

    a production machine. (nc, gcc, etc…) Why was netcat enabled?
  17. It’s an infinite ongoing process, and requires you to pay

    attention to it every single day you write or run code.
  18. Thanks! Twitter: anamus_ Blog: coming soon! Shoutout to Joona Hoikkala

    (@joohoi) for fact checking the talk in beforehand. #pystyyvetää