-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
Percent sequences seem to be interpreted when using --tomb-pwd #313
Comments
Hi Pawamoy, thanks for this result. Is indeed useful to pin down the problem.
I wonder if |
In fact Edit 1But what is printed might not correspond to what the actual values are. I see that the
(from https://linux.die.net/man/1/zshmisc, section "Expansion Of Prompt Sequences") Continuing investigation... Edit 2So it seems that |
So I wrote a script to check different passwords to see what characters will produce the issue: #!/bin/bash
# create the tombs: password will be copied in clipboard,
# so just fill the pinentry input by clicking middle-mouse button
i=1
n=$(wc -l < passwords.txt)
while read -r password; do
echo "Tomb $i/$n, password $password"
let i++
echo -n "Creating... "
tomb dig -s 10 tomb_313.tomb &>/dev/null
echo -n "$password" | xclip
tomb forge tomb_313.key &>/dev/null
tomb lock tomb_313.tomb -k tomb_313.key &>/dev/null
echo -n "Opening... "
if tomb -D --unsafe --tomb-pwd "$password" open tomb_313.tomb -k tomb_313.key 2>&1 | grep -q 'bad key'; then
echo -e "\033[;31;1mNOT OK\033[0m"
else
echo -e "\033[;32;1mOK\033[0m"
fi
echo -n "Closing... "
tomb close tomb_313 &>/dev/null
echo "Removing... "
rm tomb_313.tomb
rm tomb_313.key
echo
done < passwords.txt The file
The result is:
As we can see, it really seems that a single So, I looked back again at the code to see how it unfolds: And I fell onto these three lines (yes suspecting print again haha): https://github.com/dyne/Tomb/blob/68a9589925cca68e5368eea1754c1a5c789c355b/tomb#L980 https://github.com/dyne/Tomb/blob/68a9589925cca68e5368eea1754c1a5c789c355b/tomb#L1011-L1012 I'm gonna try the |
Finally, I think I know where the issue comes from. If I print the contents of the # Tomb 1/1, password %A__%%__%s__\\%
# tomb forge / lock / open, ask_password output:
OK Pleased to meet you
OK
OK
OK
OK
OK
D %25A__%25%25__%25s__\\%25
OK So when creating the key, locking the tomb, or opening it, if we use pinentry, the password is transformed each time the same way, and it works. But then if we use To replicate the pinentry issue: $ cat <<EOF | pinentry-gtk-2 # password typed: %s__\\%
OPTION ttyname=$(tty)
SETTITLE hello
SETDESC hello
SETPROMPT Password:
GETPIN
EOF
OK Pleased to meet you
OK
OK
OK
OK
D %25s__\\%25
OK (I was able to replicate on two different machines, but with the same OS - Debian Jessie, as well as in a ubuntu:latest Docker container.) Implications:
|
Thanks again Pawamoy for this well done analysis. |
Found relevant documentation about the behavior in ASSUAN's dev manual here at page 5
|
Nice catch! So this is not a bug 🙂 I did take a look at the For your above comment, yes, maybe we could proceed in two steps:
Doing it in two steps would let the impacted users know how to deal with this issue, without forcing them to immediatly update both passwords and Tomb version. Or, a more direct option would be to release a patch that always unescape the percent sequences, and tell users that if they want to upgrade Tomb they will need to fix their passwords containing |
Yea. I wish we'd have catched this earlier, but now is done. The manual is dated 2017 and I wonder if we could have known this by RTFM. However for now I definitely want to go for the two step and eventually leaving compatibility for it until the next major version. |
Do you want me to give it a try? If so, do you have any hints or directions (places in code where we need to check escaped and unescaped password)? I don't particularly want to put my hands in the code and would feel better if you or another author/maintainer would take this on 😅, but I still can try if nobody is willing to do so 🙂. I also checked that other pinentry alternatives print I checked pinentry-gtk-2's output for |
Thanks. I need to find some time more urgently now to review a pending PR and this issue. Don't worry if you don't feel like going forward, we got close to the issue and your contribution has been very useful for it. I'm not surprised all pinentry implementations do the same, since they all use libassuan where the parser really is. |
I analysed a bit the complexity of the two-step fixes (supported escaped and unescaped % in a transition period) and noticed:
Please anyone correct me if I'm missing something. |
So, the plan is to
Or
Anyway, I don't know the code enough but I think you are right about |
I'm leaving this as-is for now, too delicate to intervene. Best is to assume the ASSUAN's escaping is well meaning and that it is inherited in the way tomb 2.x encodes passwords. |
I think this issue is related to #304, because it's about handling passwords containing backslahes or percent signs.
This issue however only happens when using the
--tomb-pwd
(and therefore the--unsafe
) option:my password contains
%A
, and when trying to open the tomb from a script with--unsafe
and--tomb-pwd
options, the%A
simply disappears. I suspect the culprits here to be:https://github.com/dyne/Tomb/blob/68a9589925cca68e5368eea1754c1a5c789c355b/tomb#L1063-L1064
and
https://github.com/dyne/Tomb/blob/68a9589925cca68e5368eea1754c1a5c789c355b/tomb#L687-L689
Relevant part of the debug output:
The text was updated successfully, but these errors were encountered: