{"thread":{"id":"61764","subject":"Shared bare repository dubious ownership error after 2.40.1-r0","startedAt":"2024-07-10T23:25:05Z","lastAt":"2024-07-18T15:00:56Z","messageCount":3,"participants":["Mike Lodispoto","Colin Stagner","Ben Zanin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"498483","messageId":"dd703bdc-f485-4162-92a5-fd2828b69604@lodispoto.com","threadId":"61764","inReplyTo":null,"subject":"Shared bare repository dubious ownership error after 2.40.1-r0","fromName":"Mike Lodispoto","fromEmail":"mike@lodispoto.com","sentAt":"2024-07-10T23:16:50Z","receivedAt":"2024-07-10T23:25:05Z","isPatch":false,"sender":{"key":"mike@lodispoto.com","avatar":null},"body":"Hello,\n\nI use bare shared repositories on Alpine Edge, which have been working \nperfectly until I updated git recently (from 2.38.5-r0 to 2.45.2-r1).\n\nMy setup is a git user which owns all repositories (/home/git/*.git). \nEach repository has a group, so the ownership is git:projectname. The \ngroup has the same permissions as the user (-rw-rw----)\n\nTo give access to the repository, I have a user set up for the \ndeveloper, and then I add them to the group. Each repository was \ninitialized with 'git init --bare --shared'. In the config file, \n'sharedrepository = 1' is set under [core].\n\nMy issue is that somewhere between 2.40.1-r0 and 2.43.4-r0 on the \nserver, I start getting the following error on the server with a user in \nthe group, and remotely (tried with client version 2.39.2 and 2.45.2) \nthrough a user in the group:\n\n| $ git pull\n| fatal: detected dubious ownership in repository at '/home/git/project.git'\n| To add an exception for this directory, call:\n|\n|         git config --global --add safe.directory /home/git/project.git\n| fatal: Could not read from remote repository.\n|\n| Please make sure you have the correct access rights\n| and the repository exists.\n\nWhen using git 2.40.1-r0 or below, it all works and I get this:\n\n| $ git pull\n| Already up to date.\n\nIs there a breaking change I missed that I need to change my \nconfiguration for?\n\nThank you,\n\nMichael Lodispoto\n\n"},{"id":"498894","messageId":"984140ad-b2b9-4336-84db-552428071f7e@howdoi.land","threadId":"61764","inReplyTo":"dd703bdc-f485-4162-92a5-fd2828b69604@lodispoto.com","subject":"Re: Shared bare repository dubious ownership error after 2.40.1-r0","fromName":"Colin Stagner","fromEmail":"ask@howdoi.land","sentAt":"2024-07-18T04:24:34Z","receivedAt":"2024-07-18T04:24:51Z","isPatch":false,"sender":{"key":"ask@howdoi.land","avatar":null},"body":"Mike,\n\nOn 7/10/24 18:16, Mike Lodispoto wrote:\n> | $ git pull\n> | fatal: detected dubious ownership in repository at\nThis appears to be known behavior introduced as a fix for \nCVE-2024-32004. It appears that the safe.directory restrictions now \napply to fetch and clone as well. See the release notes for v2.45.1 [1].\n\nYou can fix this by adding the path containing your repositories to the \nsafe.directory configuration parameter as Git recommends. Whether or not \nyou should is another matter—this can expose your devs to attacks from \nother user accounts.\n\nI also have small workgroups that use NFS and other network filesystems \nto share repositories. Are there any plans to make cloning a local \nrepository safe?\n\nColin\n\nReferences\n\n[1]: <https://lore.kernel.org/git/xmqqv83g4937.fsf@gitster.g/>\n"},{"id":"498925","messageId":"87wmliycbe.fsf@gmail.com","threadId":"61764","inReplyTo":"dd703bdc-f485-4162-92a5-fd2828b69604@lodispoto.com","subject":"Re: Shared bare repository dubious ownership error after 2.40.1-r0","fromName":"Ben Zanin","fromEmail":"bzanin@gmail.com","sentAt":"2024-07-18T15:00:53Z","receivedAt":"2024-07-18T15:00:56Z","isPatch":false,"sender":{"key":"bzanin@gmail.com","avatar":null},"body":"\nMike,\n\nIt's a long thread that began with the proposal for a new feature, but\nthere is some valuable discussion midway down about mitigations that are\nalready in place for the symptom you're describing, and some good\nanalysis about the tradeoffs of exercising each one:\n\nhttps://lore.kernel.org/git/20240626123358.420292-1-flo@geekplace.eu/t/\n\n-- \n\tBen\n"}]}