{"thread":{"id":"58912","subject":"Git credential store conflicting configuration leads to unexpected behavior","startedAt":"2022-12-06T22:05:55Z","lastAt":"2022-12-07T12:01:27Z","messageCount":6,"participants":["Gennady Uraltsev","brian m. carlson","Philip Oakley"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"468645","messageId":"CACH4KQSutGnoyFGP2RmkwQT3yhnEg1RcvedXVSMOVVDAnz_aFg@mail.gmail.com","threadId":"58912","inReplyTo":null,"subject":"Git credential store conflicting configuration leads to unexpected behavior","fromName":"Gennady Uraltsev","fromEmail":"gennady.uraltsev@gmail.com","sentAt":"2022-12-06T22:05:22Z","receivedAt":"2022-12-06T22:05:55Z","isPatch":false,"sender":{"key":"gennady.uraltsev@gmail.com","avatar":"https://gravatar.com/avatar/5239a2b2e8a8fed34c6acf53d5636b8c328213b6796f37cae12bec8e12a182dd?d=mp&s=160"},"body":"Hello everyone,\n\nI have an issue with git credential-store. In my global configuration\ndir  (.config/git/config) I had the line\n\n[credential]\nhelper = store\n\nwhile ini a repository's .git/config while I have\n\n[credential]\nhelper = \"store --file=./.git/git-credentials\"\n\nto store credentials \"locally\".\n\nI thought the latter would overrule the former However what happens is\nthe following:\n\n1) On first run the file repo-local file ./.git/git-credentials gets\ncreated and the credentials are saved there after the user is queried\nfor a password\n2) On subsequent runs the credentials get recovered from\n./.git/git-credentials and the user is NOT asked for credentials\n2b) **Here is the weird behavior** git ALSO creates the\n.git-credentials file in the home directory and saves a copy of\ncredentials there.\n\nThe behavior 2b leads to exfiltration of passwords to a location a\nuser might not expect.\n\nWorkaround: Remove the line\n\n[credential]\nhelper = store\n\nin the global config.\n\nIt seems that the global config somehow does not get shadowed by the local one!\n\nI think this is a bug with mild security implications.\n\nLet me  know.\n\nBest,\n\nGennady\n\n--\nGennady Uraltsev\n<gennady.uraltsev@gmail.com>\n(https://guraltsev.github.io)\n"},{"id":"468646","messageId":"Y4+/VQly2NKnMrFY@tapette.crustytoothpaste.net","threadId":"58912","inReplyTo":"CACH4KQSutGnoyFGP2RmkwQT3yhnEg1RcvedXVSMOVVDAnz_aFg@mail.gmail.com","subject":"Re: Git credential store conflicting configuration leads to unexpected behavior","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2022-12-06T22:16:53Z","receivedAt":"2022-12-06T22:17:13Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2022-12-06 at 22:05:22, Gennady Uraltsev wrote:\n> Hello everyone,\n> \n> I have an issue with git credential-store. In my global configuration\n> dir  (.config/git/config) I had the line\n> \n> [credential]\n> helper = store\n> \n> while ini a repository's .git/config while I have\n> \n> [credential]\n> helper = \"store --file=./.git/git-credentials\"\n> \n> to store credentials \"locally\".\n> \n> I thought the latter would overrule the former However what happens is\n> the following:\n> \n> 1) On first run the file repo-local file ./.git/git-credentials gets\n> created and the credentials are saved there after the user is queried\n> for a password\n> 2) On subsequent runs the credentials get recovered from\n> ./.git/git-credentials and the user is NOT asked for credentials\n> 2b) **Here is the weird behavior** git ALSO creates the\n> .git-credentials file in the home directory and saves a copy of\n> credentials there.\n> \n> The behavior 2b leads to exfiltration of passwords to a location a\n> user might not expect.\n> \n> Workaround: Remove the line\n> \n> [credential]\n> helper = store\n> \n> in the global config.\n> \n> It seems that the global config somehow does not get shadowed by the local one!\n\nThis behaviour is by design.  The reason is that sometimes the user may\nhave two sets of credential helpers, one for one set of domains, and\nanother for another.  For example, I believe AWS has its own custom\ncredential helper.  Git calls credential helpers until it finds a\ncredential, and then it sends store commands to all of them.  A\ncredential helper which has no credentials for a domain will generally\nrespond with no credentials.\n\nIf you want to override the credential helpers in the `.git/config`\nfile, you can do so by first writing an empty value, like so:\n\n[credential]\nhelper =\nhelper = \"store --file=./.git/git-credentials\"\n-- \nbrian m. carlson (he/him or they/them)\nToronto, Ontario, CA\n"},{"id":"468651","messageId":"CACH4KQSj64WeqAV3CDkCXc+YW6dr+S2vN_QBj5SwcSP05fM0Eg@mail.gmail.com","threadId":"58912","inReplyTo":"Y4+/VQly2NKnMrFY@tapette.crustytoothpaste.net","subject":"Re: Git credential store conflicting configuration leads to unexpected behavior","fromName":"Gennady Uraltsev","fromEmail":"gennady.uraltsev@gmail.com","sentAt":"2022-12-06T23:53:05Z","receivedAt":"2022-12-06T23:53:36Z","isPatch":false,"sender":{"key":"gennady.uraltsev@gmail.com","avatar":"https://gravatar.com/avatar/5239a2b2e8a8fed34c6acf53d5636b8c328213b6796f37cae12bec8e12a182dd?d=mp&s=160"},"body":"Thank you!\n\nThis makes sense and the solution is simple. Is this somewhere in the\ndocumentation (honest question, I am not being a jerk)? I tried my\nbest to figure this out before bugging people on the mailinglist.\n\nBest,\n\nGennady\n\n--\nGennady Uraltsev\n<gennady.uraltsev@gmail.com>\n(https://guraltsev.github.io)\n\n\nOn Tue, Dec 6, 2022 at 5:16 PM brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n>\n> On 2022-12-06 at 22:05:22, Gennady Uraltsev wrote:\n> > Hello everyone,\n> >\n> > I have an issue with git credential-store. In my global configuration\n> > dir  (.config/git/config) I had the line\n> >\n> > [credential]\n> > helper = store\n> >\n> > while ini a repository's .git/config while I have\n> >\n> > [credential]\n> > helper = \"store --file=./.git/git-credentials\"\n> >\n> > to store credentials \"locally\".\n> >\n> > I thought the latter would overrule the former However what happens is\n> > the following:\n> >\n> > 1) On first run the file repo-local file ./.git/git-credentials gets\n> > created and the credentials are saved there after the user is queried\n> > for a password\n> > 2) On subsequent runs the credentials get recovered from\n> > ./.git/git-credentials and the user is NOT asked for credentials\n> > 2b) **Here is the weird behavior** git ALSO creates the\n> > .git-credentials file in the home directory and saves a copy of\n> > credentials there.\n> >\n> > The behavior 2b leads to exfiltration of passwords to a location a\n> > user might not expect.\n> >\n> > Workaround: Remove the line\n> >\n> > [credential]\n> > helper = store\n> >\n> > in the global config.\n> >\n> > It seems that the global config somehow does not get shadowed by the local one!\n>\n> This behaviour is by design.  The reason is that sometimes the user may\n> have two sets of credential helpers, one for one set of domains, and\n> another for another.  For example, I believe AWS has its own custom\n> credential helper.  Git calls credential helpers until it finds a\n> credential, and then it sends store commands to all of them.  A\n> credential helper which has no credentials for a domain will generally\n> respond with no credentials.\n>\n> If you want to override the credential helpers in the `.git/config`\n> file, you can do so by first writing an empty value, like so:\n>\n> [credential]\n> helper =\n> helper = \"store --file=./.git/git-credentials\"\n> --\n> brian m. carlson (he/him or they/them)\n> Toronto, Ontario, CA\n"},{"id":"468666","messageId":"Y4/pO55b5DtPnavg@tapette.crustytoothpaste.net","threadId":"58912","inReplyTo":"CACH4KQSj64WeqAV3CDkCXc+YW6dr+S2vN_QBj5SwcSP05fM0Eg@mail.gmail.com","subject":"Re: Git credential store conflicting configuration leads to unexpected behavior","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2022-12-07T01:15:39Z","receivedAt":"2022-12-07T01:15:45Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2022-12-06 at 23:53:05, Gennady Uraltsev wrote:\n> Thank you!\n> \n> This makes sense and the solution is simple. Is this somewhere in the\n> documentation (honest question, I am not being a jerk)? I tried my\n> best to figure this out before bugging people on the mailinglist.\n\nYes, but maybe not where you'd expect.  In gitcredentials(7), there's\nthis text:\n\n  If there are multiple instances of the `credential.helper` configuration\n  variable, each helper will be tried in turn, and may provide a username,\n  password, or nothing. Once Git has acquired both a username and a\n  password, no more helpers will be tried.\n\n  If `credential.helper` is configured to the empty string, this resets\n  the helper list to empty (so you may override a helper set by a\n  lower-priority config file by configuring the empty-string helper,\n  followed by whatever set of helpers you would like).\n\nThe `credential.helper` option mentions that manual page.\n-- \nbrian m. carlson (he/him or they/them)\nToronto, Ontario, CA\n"},{"id":"468669","messageId":"CACH4KQSJ_3J4qvbbv1+4URg4hpXAur3pzvMouXRkF8WsLVWhRg@mail.gmail.com","threadId":"58912","inReplyTo":"Y4/pO55b5DtPnavg@tapette.crustytoothpaste.net","subject":"Re: Git credential store conflicting configuration leads to unexpected behavior","fromName":"Gennady Uraltsev","fromEmail":"gennady.uraltsev@gmail.com","sentAt":"2022-12-07T01:19:44Z","receivedAt":"2022-12-07T01:20:15Z","isPatch":false,"sender":{"key":"gennady.uraltsev@gmail.com","avatar":"https://gravatar.com/avatar/5239a2b2e8a8fed34c6acf53d5636b8c328213b6796f37cae12bec8e12a182dd?d=mp&s=160"},"body":"Thank you! I did miss it. I appreciate your time.\n\n--\nGennady Uraltsev\n<gennady.uraltsev@gmail.com>\n(https://guraltsev.github.io)\n\n\nOn Tue, Dec 6, 2022 at 8:15 PM brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n>\n> On 2022-12-06 at 23:53:05, Gennady Uraltsev wrote:\n> > Thank you!\n> >\n> > This makes sense and the solution is simple. Is this somewhere in the\n> > documentation (honest question, I am not being a jerk)? I tried my\n> > best to figure this out before bugging people on the mailinglist.\n>\n> Yes, but maybe not where you'd expect.  In gitcredentials(7), there's\n> this text:\n>\n>   If there are multiple instances of the `credential.helper` configuration\n>   variable, each helper will be tried in turn, and may provide a username,\n>   password, or nothing. Once Git has acquired both a username and a\n>   password, no more helpers will be tried.\n>\n>   If `credential.helper` is configured to the empty string, this resets\n>   the helper list to empty (so you may override a helper set by a\n>   lower-priority config file by configuring the empty-string helper,\n>   followed by whatever set of helpers you would like).\n>\n> The `credential.helper` option mentions that manual page.\n> --\n> brian m. carlson (he/him or they/them)\n> Toronto, Ontario, CA\n"},{"id":"468706","messageId":"aa8a0d4b-961f-cdad-6e67-452ac945ed1e@iee.email","threadId":"58912","inReplyTo":"CACH4KQSj64WeqAV3CDkCXc+YW6dr+S2vN_QBj5SwcSP05fM0Eg@mail.gmail.com","subject":"Re: Git credential store conflicting configuration leads to unexpected behavior","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.email","sentAt":"2022-12-07T12:01:21Z","receivedAt":"2022-12-07T12:01:27Z","isPatch":false,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"On 06/12/2022 23:53, Gennady Uraltsev wrote:\n> Thank you!\n>\n> This makes sense and the solution is simple. Is this somewhere in the\n> documentation (honest question, I am not being a jerk)? I tried my\n> best to figure this out before bugging people on the mailinglist.\n\nI think it's all hidden in the docs, but isn't easy to tease out.\n\nThe 'override a multi-value config with a leading empty value\"\ntechnique, I think, is covered in the general discussions about how\nconfig values are entered and parsed.\n\nA useful question would be to ask, where did, or would, you look to hope\nto find this information? If we put the info in the right place,\nsufficient folks will read it.\n\nPhilip\nPS in-line posting preferred.  \n\n>\n> Best,\n>\n> Gennady\n>\n> --\n> Gennady Uraltsev\n> <gennady.uraltsev@gmail.com>\n> (https://guraltsev.github.io)\n>\n>\n> On Tue, Dec 6, 2022 at 5:16 PM brian m. carlson\n> <sandals@crustytoothpaste.net> wrote:\n>> On 2022-12-06 at 22:05:22, Gennady Uraltsev wrote:\n>>> Hello everyone,\n>>>\n>>> I have an issue with git credential-store. In my global configuration\n>>> dir  (.config/git/config) I had the line\n>>>\n>>> [credential]\n>>> helper = store\n>>>\n>>> while ini a repository's .git/config while I have\n>>>\n>>> [credential]\n>>> helper = \"store --file=./.git/git-credentials\"\n>>>\n>>> to store credentials \"locally\".\n>>>\n>>> I thought the latter would overrule the former However what happens is\n>>> the following:\n>>>\n>>> 1) On first run the file repo-local file ./.git/git-credentials gets\n>>> created and the credentials are saved there after the user is queried\n>>> for a password\n>>> 2) On subsequent runs the credentials get recovered from\n>>> ./.git/git-credentials and the user is NOT asked for credentials\n>>> 2b) **Here is the weird behavior** git ALSO creates the\n>>> .git-credentials file in the home directory and saves a copy of\n>>> credentials there.\n>>>\n>>> The behavior 2b leads to exfiltration of passwords to a location a\n>>> user might not expect.\n>>>\n>>> Workaround: Remove the line\n>>>\n>>> [credential]\n>>> helper = store\n>>>\n>>> in the global config.\n>>>\n>>> It seems that the global config somehow does not get shadowed by the local one!\n>> This behaviour is by design.  The reason is that sometimes the user may\n>> have two sets of credential helpers, one for one set of domains, and\n>> another for another.  For example, I believe AWS has its own custom\n>> credential helper.  Git calls credential helpers until it finds a\n>> credential, and then it sends store commands to all of them.  A\n>> credential helper which has no credentials for a domain will generally\n>> respond with no credentials.\n>>\n>> If you want to override the credential helpers in the `.git/config`\n>> file, you can do so by first writing an empty value, like so:\n>>\n>> [credential]\n>> helper =\n>> helper = \"store --file=./.git/git-credentials\"\n>> --\n>> brian m. carlson (he/him or they/them)\n>> Toronto, Ontario, CA\n\n"}]}