theskumar / theskumar/python-dotenv
Configure `dotenv_values`'s search space
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.9k
- Forks
- 581
- PR merge metrics
- No merged PRs in 30d
Description
Currently the user-specified path could point to any folder and dotenv will parse them anyway even if it is files like /etc/passwd.
The content of the target file would be available in the error message. This could potentially introduce the path traversal vulnerability if the developer misuses it.
from dotenv import load_dotenv
from dotenv import dotenv_values
import os
config = dotenv_values("../../../etc/passwd")
I am wondering if it is possible to give dotenv_values an additional arguments to control if it would support relative path searching.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the dotenv_values entry point and the path-handling behavior shown in the example. Done should establish a clear way to control relative-path searching and prevent unintended files such as /etc/passwd from being parsed or exposed; no test file is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100