Security Best Practice: Laravel
Security Best Practice: Laravel
SECURITY BEST
PRACTICE
Secure Coding Community
The Secure Coding community has been formed with the aim of increasing security
awareness and knowledge at the application layer.
This group has no spiritual or financial affiliation with any institution or organization
and is dependent on its members to continue its activities.
Ways to communicate with the community
Email: [email protected]
ﺑﺎ ﻫﺪف اﻓﺰاﯾﺶ آﮔﺎﻫﯽ و داﻧﺶ اﻣﻨﯿﺖ در ﻻﯾﻪSECURE CODING ﺟﺎﻣﻌﻪ و اﻧﺠﻤﻦ ﮐﺪﻧﻮﯾﺴﯽ اﻣﻦ ﯾﺎ
.اﭘﻠﮑﯿﯿﺸﻦ ﺗﺸﮑﯿﻞ ﺷﺪه اﺳﺖ
اﯾﻦ ﻣﺠﻤﻮﻋﻪ ﻫﯿﺞ واﺑﺴﺘﮕﯽ ﻣﻌﻨﻮی و ﻣﺎﻟﯽ ﺑﻪ ﻫﯿﭻ ﻧﻬﺎد و ﺳﺎزﻣﺎﻧﯽ ﻧﺪارد و ﺑﺮای اداﻣﻪ ﻓﻌﺎﻟﯿﺖ ﺧﻮد
.واﺑﺴﺘﻪ ﺑﻪ اﻋﻀﺎی آن اﺳﺖ
راه ﻫﺎی ارﺗﺒﺎﻃﯽ ﺑﺎ اﻧﺠﻤﻦ
[email protected] :اﯾﻤﯿﻞ
0
SUBJECTS
What is laravel
CSRF
Password hashing
Cookies protection
Encryption
Session management
XSS Prevention
Security Issue
Sql Injection
XSS
Privilage Escalation
Insecure Deserialization
Insecure Logging
IDOR
SSRF
Mass Assignment
Security Package
Security Checklist
0
WHAT IS LARAVEL
Laravel is a web application framework with expressive, elegant
Laravel uses the Form Classes Token Method (for short, CSRF token),
which is enabled by default. You can see the token and a predefined
In the most simple terms, CSRF protection makes sure that each
request actually comes for your app, not a potential XSS attack by a
Password hashing
documentation).
1
LARAVEL’S BUILT-IN SECURITY FEATURES
Password hashing
process.
There are also other actions you can take to further build upon this
Cookies protection
Laravel will also make sure your cookies are bullet-proof, provided
that you create and enable an application key (also known as the
encryption key).
Depending on the Laravel version you’re working on, you’ll either need
to add the key to the app.php file in the config folder (versions 5 and
3 and below).
Encryption
2
LARAVEL’S BUILT-IN SECURITY FEATURES
Session management
XSS Prevention
form’s text areas) into your website. Now, whenever new visitors will
access the affected page of form, the script will be executed with
malicious impact.
Laravel’s Eloquent ORM uses PDO binding that protects from SQL
injections. This feature ensures that no client could modify the intent
queries. Yet, Eloquent remains the most popular option. Learning how
3
SECURITY ISSUE
Server Side Template Injection
injection.
4
SECURITY ISSUE
Server Side Template Injection
remote code execution, taking full control of the backend server and
attacker can often still use server-side template injection as the basis
Sql Injection
It generally allows an attacker to view data that they are not normally
5
SECURITY ISSUE
Sql Injection
period.
XSS
6
SECURITY ISSUE
XSS
out any actions that the user is able to perform, and to access any of
the user’s data. If the victim user has privileged access within the
application, then the attacker might be able to gain full control over
of the application, its functionality and data, and the status of the
compromised user.
7
SECURITY ISSUE
Privilage Escalation
Based off the name of the machine, and after not having much luck
The last line seems interesting… seems like artisan is being executed
-rw-r — r —
Editing artisan:
This will download the php reverse shell from my host, and pipe it into
php to execute.
8
SECURITY ISSUE
Insecure Deserialization
was serialized. The website’s logic can then interact with this
is finished.
9
SECURITY ISSUE
Insecure Deserialization
interact with the malicious object. For this reason, websites whose
these techniques.
execution.
10
SECURITY ISSUE
Insecure Logging
does the solution. For that reason, we will not limit this discussion to
One of the primary problems is that there are so many logs — almost
thus becomes a major problem. By the time that all the different logs
are gathered together and preferably collated, the sheer size of the
11
SECURITY ISSUE
IDOR
12
SECURITY ISSUE
SSRF
attacker’s choosing.
systems.
13
SECURITY ISSUE
SSRF
the breach.
However, other functions (here PHP) can also be the source of the
breach.
file_get_contents()
fopen()
fread()
fsockopen()
curl_exec()
14
SECURITY ISSUE
Mass Assignment
This can sometimes cause harm. Attackers can sometimes use this
could alter the form on the client side and add a new input to it:
Cat::create(Request::all())
15
SECURITY PACKAGE
https://github.com/getspooky/Laravel-Mitnick
Cache Control
X-Permitted-Cross-Domain-Policies
DNS Prefetch
Strict-Transport-Security
X-Powered-By Attack
XSS Attack
16
SECURITY CHECKLIST
Keep Update Laravel
Always use the latest version of Laravel and PHP (keep updated)
Use HTTPS
17
RESOURCES
portswigger.net/web-security
cheatsheetseries.owasp.org
asperbrothers.com
cloudways.com
laravel-news.com
aglowiditsolutions.com
blog.haao.sh
blog.truesec.com
immuniweb.com
github.com/appelsiini/vulnerable-laravel-app
2hatslogic.com
ctf-wiki.github.io
vaadata.com
morioh.com/p/28504689f3bc
18