InfoSec Write-ups

A collection of write-ups from the best hackers in the world on topics ranging from bug bounties and CTFs to vulnhub machines, hardware challenges and real life encounters. Subscribe to our weekly newsletter for the coolest infosec updates: https://weekly.infosecwriteups.com/

Follow publication

Member-only story

The Big Danger With Laravel ( .env file )

Ismail Tasdelen
InfoSec Write-ups
Published in
3 min readDec 27, 2022

--

The Big Danger With Laravel ( .env file )

In this article, I will be talking about a danger that comes with Laravel. The .env file in Laravel is a configuration file that contains sensitive information such as database credentials and API keys. It is important to keep this file secure and out of reach of unauthorized users.

One potential security vulnerability with the .env file in Laravel is that it is not included in the version control system (e.g. Git) by default. This means that if you are using version control for your Laravel project, the .env file will not be tracked and any changes made to it will not be reflected in the version control history. This can make it difficult to track changes to the .env file and to keep it in sync between different environments (e.g. development, staging, production).

To address this issue, you can include the .env file in version control by adding it to the .gitignore file with a ! prefix. This will tell Git to track the .env file even though it is normally ignored.

For example:

# Ignore everything in the root except the .env file
/*
!.env

It is also a good practice to keep the .env file outside the document root of your web server. This will prevent unauthorized users from being able to access the file directly through the web.

--

--

Published in InfoSec Write-ups

A collection of write-ups from the best hackers in the world on topics ranging from bug bounties and CTFs to vulnhub machines, hardware challenges and real life encounters. Subscribe to our weekly newsletter for the coolest infosec updates: https://weekly.infosecwriteups.com/

Written by Ismail Tasdelen

I'm Ismail Tasdelen. I have been working in the cyber security industry for +7 years. Don't forget to follow and applaud to support my content.

Responses (14)

Write a response