Social card titled Running Scripts Without Permission, a Linux security note on how bash runs non-executable scripts

Power to you.

—

by

in

Read Time

1–2 minutes

Linux permissions: you don’t always need access, just access to someone who has it

With that said. Most of the times you dont even need access to do somethin. You just need access to someone who has access.

Lets say i am a normal user and i need to run a script in linux where the file nor me have permission and access to run or change the permission

Running test.sh directly fails without execute permission, while passing it to /bin/bash runs it without changing its permissions
bash has the permission, so whatever you hand it gets run.
Linux terminal as a normal user with a script that has no execute permission
Terminal showing the normal user has no rights to change the script's permissions

File listing showing test.sh without execute permission

If you see the test.sh file. It does not have access to run.

BBBUUUTTTTTTTT…..

test.sh running successfully when passed to /bin/bash, with no permission change

SEEEEEEE…..

It ran without doing any changes to its permission.

Permissions of /bin/bash, which every user is allowed to execute

Since /bin/bash has the permission, if you run the program with it then it shall work

This is why you need to be very careful when giving permission and this is how hackers get access in some cases.