Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security with header X-Forwarded-For and API_TOKEN #90

Open
thib3113 opened this issue May 28, 2024 · 1 comment
Open

Security with header X-Forwarded-For and API_TOKEN #90

thib3113 opened this issue May 28, 2024 · 1 comment

Comments

@thib3113
Copy link

thib3113 commented May 28, 2024

Please add some security points to this project .

First this part

if (request.headers.get("x-forwarded-for") !== null) {
ip = request.headers.get("x-forwarded-for").split(",")[0];
} else if (request.headers.get("x-real-ip") !== null) {
ip = request.headers.get("x-real-ip");

allow a user to fake ip .

Creating the query on curl, you can add your custom X-Forwarded-For, and so fake the sender ip .

You need to trust headers x-forwarded-for or x-real-ip only if remoteAddress is a trusted reverse proxy . So you need to add an env to set the list of trusted reverse proxies, and check .


Second, please doesn't use API_TOKEN in clear . It's really better to set a hash on the env variable, and in your script you can check if the hash match the sent Bearer .

you can easly use bcrypt . and you can easily find a bcrypt generator online to get an hash

this is not the best solution, but better than setting the password in clear in env ... also, you can use docker files environment var, it allow to use a secret - example on mongodb image

@thib3113 thib3113 changed the title Security Security with header X-Forwarded-For and API_TOKEN May 28, 2024
@rajnandan1
Copy link
Owner

Hi @thib3113 can you raise a PR with the desired fixes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants