summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2014-04-18 13:22:39 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2014-04-18 13:22:39 +0200
commit1edc1a7ecc74798484b690db0f88b9ac30120162 (patch)
tree4d5e4482a22e1df0f83fdef386903e6231786953
parent8066a2b222a31cf5ac217de5e26a267a2100940e (diff)
downloadpass-1edc1a7ecc74798484b690db0f88b9ac30120162.tar.gz
pass-1edc1a7ecc74798484b690db0f88b9ac30120162.tar.bz2
pass-1edc1a7ecc74798484b690db0f88b9ac30120162.zip
Check sneaky paths.
Diffstat (limited to '')
-rwxr-xr-xsrc/password-store.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/password-store.sh b/src/password-store.sh
index f80f026..4874175 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -114,6 +114,14 @@ reencrypt_path() {
prev_gpg_recipients="${GPG_RECIPIENTS[@]}"
done
}
+check_sneaky_paths() {
+ for path in "$@"; do
+ if [[ $path =~ /\.\.$ || $path =~ ^\.\./ || $path =~ /\.\./ || $path =~ ^\.\.$ ]]; then
+ echo "Error: You've attempted to pass a sneaky path to pass. Go home."
+ exit 1
+ fi
+ done
+}
#
# END helper functions
@@ -256,6 +264,7 @@ cmd_init() {
echo "Usage: $PROGRAM $COMMAND [--path=subfolder,-p subfolder] gpg-id..."
exit 1
fi
+ [[ -n $id_path ]] && check_sneaky_paths "$id_path"
if [[ -n $id_path && ! -d $PREFIX/$id_path ]]; then
if [[ -e $PREFIX/$id_path ]]; then
echo "Error: $PREFIX/$id_path exists but is not a directory."
@@ -309,6 +318,7 @@ cmd_show() {
local path="$1"
local passfile="$PREFIX/$path.gpg"
+ check_sneaky_paths "$path"
if [[ -f $passfile ]]; then
if [[ $clip -eq 0 ]]; then
exec $GPG -d $GPG_OPTS "$passfile"
@@ -396,6 +406,7 @@ cmd_insert() {
fi
local path="$1"
local passfile="$PREFIX/$path.gpg"
+ check_sneaky_paths "$path"
[[ $force -eq 0 && -e $passfile ]] && yesno "An entry already exists for $path. Overwrite it?"
@@ -436,6 +447,7 @@ cmd_edit() {
fi
local path="$1"
+ check_sneaky_paths "$path"
mkdir -p -v "$PREFIX/$(dirname "$path")"
set_gpg_recipients "$(dirname "$path")"
local passfile="$PREFIX/$path.gpg"
@@ -481,6 +493,7 @@ cmd_generate() {
fi
local path="$1"
local length="$2"
+ check_sneaky_paths "$path"
if [[ ! $length =~ ^[0-9]+$ ]]; then
echo "pass-length \"$length\" must be a number."
exit 1
@@ -522,6 +535,7 @@ cmd_delete() {
exit 1
fi
local path="$1"
+ check_sneaky_paths "$path"
local passfile="$PREFIX/${path%/}"
if [[ ! -d $passfile ]]; then
@@ -560,6 +574,7 @@ cmd_copy_move() {
echo "Usage: $PROGRAM $COMMAND [--force,-f] old-path new-path"
exit 1
fi
+ check_sneaky_paths "$@"
local old_path="$PREFIX/${1%/}"
local new_path="$PREFIX/$2"
local old_dir="$old_path"
-highlight'> 2012-09-06Use more normal sleep variant.1.1.1Jason A. Donenfeld1-1/+1 2012-09-06Use --noreport instead of head -n -2 for tree so that it works on mac.Jason A. Donenfeld1-1/+1 Reported-by: Theo Belaire <tbelaire@uwaterloo.ca> 2012-09-05Be sure to explicitly state that install is a phony target.Jason A. Donenfeld1-0/+2 2012-09-05Bump debian version horribly.1.1Jason A. Donenfeld2-2/+2 2012-09-04No echo mode.Jason A. Donenfeld2-16/+42 Add a --no-echo flag to the insert operation so that the password isn't echoed when entering it. This requires the user to echo the password twice for confirmation. Reported-by: Dominic Lüchinger <d.luechinger@snowgarden.ch> 2012-09-04Properly quote the path too.Jason A. Donenfeld1-1/+1 2012-09-04Allow passwords having spaces to go unbroken to the clipboard.Bernardo Freitas Paulo da Costa1-1/+1 This also prevents showing the second <word> of the password in the prompt. 2012-09-04Separate out the massive git example.Jason A. Donenfeld1-10/+14 2012-09-04Prepare for debianification.1.0Jason A. Donenfeld9-4/+60 2012-09-03Fix readme typo.Jason A. Donenfeld1-1/+1 2012-09-03Show program name properly in error message.Jason A. Donenfeld1-1/+1 2012-09-03Move examples into manpage.Jason A. Donenfeld4-93/+224 2012-09-03Make into a real project.Jason A. Donenfeld8-5/+173 2012-09-03Support pass gitJason A. Donenfeld2-1/+15 2012-08-31Add remove synonyms.Jason A. Donenfeld1-2/+2 2012-08-31Use basename in usage.Jason A. Donenfeld1-2/+1 2012-08-19now using gpg_id as a varMatthew Ramirez1-2/+2 2012-08-07Forty five seconds.Jason A. Donenfeld1-1/+1 2012-08-06Deal with klipper and new lines.Jason A. Donenfeld1-3/+19 2012-08-06Update examples.Jason A. Donenfeld1-7/+7 2012-08-06Update readme.Jason A. Donenfeld1-11/+13 2012-08-06Be slicker and more like git.Jason A. Donenfeld1-114/+173