From: "M Hickford via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: sandals@crustytoothpaste.net, stolee@gmail.com,
Johannes.Schindelin@gmx.de, peff@peff.net,
rsbecker@nexbridge.com, Johannes.Schindelin@gmx.de,
M Hickford <mirth.hickford@gmail.com>,
M Hickford <mirth.hickford@gmail.com>
Subject: [PATCH] credential: warn about git-credential-store [RFC]
Date: Fri, 31 Jan 2025 19:48:06 +0000 [thread overview]
Message-ID: <pull.1856.git.1738352886190.gitgitgadget@gmail.com> (raw)
From: M Hickford <mirth.hickford@gmail.com>
git-credential-store saves secrets unencrypted on disk.
Warn the user before they type their password, suggesting alternative
credential helpers.
An alternative could be to warn in "credential-store store". A
disadvantage is that the user wouldn't see the warning until after they
typed their password, which is less helpful. The warning would appear
again every time the user authenticated, which feels too frequently.
Signed-off-by: M Hickford <mirth.hickford@gmail.com>
---
credential: warn about git-credential-store [RFC]
RFC for discussion. Some tests fail
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1856%2Fhickford%2Fstore-warn-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1856/hickford/store-warn-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1856
credential.c | 6 +++++-
t/lib-credential.sh | 2 ++
t/t0302-credential-store.sh | 3 +++
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/credential.c b/credential.c
index 2594c0c4229..6e05bba7e2f 100644
--- a/credential.c
+++ b/credential.c
@@ -285,9 +285,13 @@ static int credential_getpass(struct repository *r, struct credential *c)
if (!c->username)
c->username = credential_ask_one("Username", c,
PROMPT_ASKPASS|PROMPT_ECHO);
- if (!c->password)
+ if (!c->password) {
+ if (c->helpers.nr >= 1 && starts_with(c->helpers.items[0].string, "store"))
+ warning("git-credential-store saves passwords unencrypted on disk. For alternatives, see gitcredentials(7).");
+
c->password = credential_ask_one("Password", c,
PROMPT_ASKPASS);
+ }
trace2_region_leave("credential", "interactive", r);
return 0;
diff --git a/t/lib-credential.sh b/t/lib-credential.sh
index 58b9c740605..47483f09006 100644
--- a/t/lib-credential.sh
+++ b/t/lib-credential.sh
@@ -67,6 +67,8 @@ reject() {
helper_test() {
HELPER=$1
+ # help wanted: expect warning "git-credential-store saves passwords
+ # unencrypted" when helper equals "store"
test_expect_success "helper ($HELPER) has no existing data" '
check fill $HELPER <<-\EOF
protocol=https
diff --git a/t/t0302-credential-store.sh b/t/t0302-credential-store.sh
index c1cd60edd01..349b5f0b084 100755
--- a/t/t0302-credential-store.sh
+++ b/t/t0302-credential-store.sh
@@ -133,6 +133,7 @@ invalid_credential_test() {
password=askpass-password
--
askpass: Username for '\''https://example.com'\'':
+ warning: git-credential-store saves passwords unencrypted on disk. For alternatives, see gitcredentials(7) or https://git-scm.com/doc/credential-helpers.
askpass: Password for '\''https://askpass-username@example.com'\'':
--
EOF
@@ -155,6 +156,7 @@ test_expect_success 'get: credentials with DOS line endings are invalid' '
password=askpass-password
--
askpass: Username for '\''https://example.com'\'':
+ warning: git-credential-store saves passwords unencrypted on disk. For alternatives, see gitcredentials(7) or https://git-scm.com/doc/credential-helpers.
askpass: Password for '\''https://askpass-username@example.com'\'':
--
EOF
@@ -186,6 +188,7 @@ test_expect_success 'get: credentials with DOS line endings are invalid if path
password=askpass-password
--
askpass: Username for '\''https://example.com/repo.git'\'':
+ warning: git-credential-store saves passwords unencrypted on disk. For alternatives, see gitcredentials(7) or https://git-scm.com/doc/credential-helpers.
askpass: Password for '\''https://askpass-username@example.com/repo.git'\'':
--
EOF
base-commit: 4e746b1a31f9f0036032b6f94279cf16fb363203
--
gitgitgadget
next reply other threads:[~2025-01-31 19:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-31 19:48 M Hickford via GitGitGadget [this message]
2025-01-31 20:05 ` [PATCH] credential: warn about git-credential-store [RFC] Junio C Hamano
2025-02-01 2:54 ` Jeff King
2025-02-02 23:41 ` Junio C Hamano
2025-02-01 10:07 ` brian m. carlson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.1856.git.1738352886190.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=mirth.hickford@gmail.com \
--cc=peff@peff.net \
--cc=rsbecker@nexbridge.com \
--cc=sandals@crustytoothpaste.net \
--cc=stolee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).