In Git, always "sudo" to the daemon user if a daemon user is configured
commit3125d7a5f48d612c5e97aa2b13acafb50b6a0b9c
authorepriestley <git@epriestley.com>
Wed, 13 Apr 2022 18:13:31 +0000 (13 11:13 -0700)
committerepriestley <git@epriestley.com>
Wed, 13 Apr 2022 18:23:55 +0000 (13 11:23 -0700)
tree23a00f94ee9e6e0516651c136210283e7e215dd8
parent4dae3e7e1fbf462a8b77f654b8e990dfd9fa7942
In Git, always "sudo" to the daemon user if a daemon user is configured

Summary:
See T13673. Recent versions of Git (and older versions with backported security patches) now refuse to run Git commands if the top-level repository directory is not owned by the user running the command.

Currently, we "sudo" to that user only when performing writes, so upgrading Git can aggressively break a Phabricator system by knocking out essentially all Diffusion/Conduit read pathways.

As an immediate mitigation, just "sudo" in all cases where a daemon user is available. This fixes the problem, and seems like the least-bad approach. The downside is that the web user may theoretically have fewer privileges than the daemon user and this could reduce the number of layers an attacker armed with some other Git vulnerability might have to get through to do something dangerous (e.g., perform a write on a pathway where only reads are expected), but any separation between the web and daemon accounts is essentially theoretical and has never been enforced.

Test Plan: Applied patch to impacted Phacility shard, saw Diffusion work properly again.

Differential Revision: https://secure.phabricator.com/D21756
src/applications/diffusion/protocol/DiffusionCommandEngine.php
src/applications/diffusion/protocol/DiffusionGitCommandEngine.php