Skip to content

Conversation

@ogr3
Copy link
Contributor

@ogr3 ogr3 commented Mar 20, 2017

The approach is to wait with evaluation of the parts that contain the branch names until PS1 is rendered.

This patch handles both the ordinary branch name as well as the upstream branch name.

Try to fix #310.

Credits to @chmike and @jayrhynas

Steps to reproduce the bug and see if the fix works:

git clone https://github.com/njhartwell/pw3nage.git
cd pw3nage
GIT_PROMPT_SHOW_UPSTREAM=1
unset GIT_PROMPT_SHOW_UPSTREAM

Expected result when fixed without upstream info:

[$(./pw3n)|✔] ✔

With upstream info:

[$(./pw3n) {origin/$(./pw3n)}|✔] ✔

@ogr3
Copy link
Contributor Author

ogr3 commented Mar 20, 2017

Good catch - makes the patch even leaner.

@ogr3 ogr3 changed the title Wait with evaluation of the parts that contain the branch names until… [security] Fix for #310 Mar 21, 2017
@magicmonty magicmonty merged commit 46aaea2 into magicmonty:master Mar 26, 2017
@magicmonty
Copy link
Owner

Seems to work for me. Thanks @ogr3

@MPLew-is MPLew-is mentioned this pull request May 18, 2020
MPLew-is added a commit to MPLew-is/bash-git-prompt that referenced this pull request Dec 1, 2020
The differences between bash and zsh's prompt evaluation apparently results in one fewer level of evaluation under zsh than bash, meaning that the security fix in magicmonty#313 results in the branch name not bein rendered on zsh.
This just disables the fix, since zsh does not seem to be vulnerable to the same issue.
@MPLew-is
Copy link
Contributor

@guenhter your recent changes have un-done this fix - running the reproduction steps above again on the latest master results in arbitrary code execution!

@MPLew-is
Copy link
Contributor

Looks like I was too hasty to assign blame, and running a git bisect shows it was @magicmonty that un-did this in 21063bc.

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

Successfully merging this pull request may close these issues.

Security issue with bash-git-prompt ?

4 participants