esp-idf/docs/en/api-guides
Frantisek Hrbata 99f9dd4c07 feat(docker): allow to add paths into git's safe.directory
With 8959555cee7e[1] ("setup_git_directory(): add an owner check for the top..")
git added an ownership check of the git directory and refuses to
run any git commands, even parsing the config file, if the git directory
is not owned by the current user. The "fatal: detected dubious ownership in repository"
is reported.

This fixes CVE-2022-24765[2], which allows to compromise user account. On a
multi-user system or e.g. on a shared file system, one user may create a "rogue"
git repository with e.g. core.fsmonitor set to an arbitrary command. Other user
may unwillingly execute this command by running e.g. git-diff or
git-status within the "rogue" git repository, which may be in one of the parent
directories. If e.g. PS1 is set to display information about a git
repository in CWD, as suggested in Git in Bash[3], the user do not need to run
any git command to trigger this, just entering some subdirectory under
this "rogue" git repository is enough, because the git command will be
started transparently through the script used in PS1. The core.fsmonitor
can be set to arbitrary command. It's purpose is to help git to identify changed files
and speed up the scanning for changed files.

rogue
├── .git     # owned by user1
└── dir1     # owned by user2
    ├── dir2 # owned by user2
    └── .git # owned by user2

user1 sets core.fsmonitor for git repository in rogue directory
$ git config --add core.fsmonitor "bash -c 'rm -rf \$HOME'"

user2 enters dir1 and runs e.g. git diff and triggers the core.fsmonitor command.

The ownership check may cause problems when running git commands in
ESP-IDF Docker container. For example user may run the container as
root, but the mounted project may be owned by a particular user.

In this case git will refuse to execute any git command within the
"/project" directory, because it's not owned by root. To overcome this,
git allows to set safe.directories, for which the ownership check is
skipped. The security check may be completely disabled by setting
safe.directories to "*". This solution was proposed in PR 12636[4], but
it would allow make it possible to exploit this vulnerability again.

This fix allows user to specify git's safe.directory in IDF_GIT_SAFE_DIR
environmental variable, which may be set during container startup.

The IDF_GIT_SAFE_DIR has same format as PATH and multiple directories can be
specified by using a ":" separator. To entirely disable this git security check
within the container, user may set IDF_GIT_SAFE_DIR='*'. This might be
heplfull in CI.

Closes https://github.com/espressif/esp-idf/pull/12636

[1] - 8959555cee
[2] - https://nvd.nist.gov/vuln/detail/cve-2022-24765
[3] - https://git-scm.com/book/en/v2/Appendix-A%3A-Git-in-Other-Environments-Git-in-Bash
[4] - https://github.com/espressif/esp-idf/pull/12636

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2023-12-01 08:23:16 +01:00
..
esp-ble-mesh docs: fixed misc broken links 2022-09-18 15:03:39 +08:00
inc docs: provide CN translation for linux-host-requirements.rst and external-ram-esp32-notes.rst (backport v5.1) 2023-07-05 12:29:08 +08:00
jtag-debugging fix(docs/jtag): Fix hard-coded HW breakpoints/watchpoints number 2023-10-16 17:30:36 +03:00
performance docs: add the description of CONFIG_MBEDTLS_USE_CRYPTO_ROM_IMPL 2023-10-26 20:26:19 +08:00
sleep-current add low power doc and picture 2023-08-28 14:07:45 +08:00
tools feat(docker): allow to add paths into git's safe.directory 2023-12-01 08:23:16 +01:00
app_trace.rst docs: update CN for api-guides/app_trace.rst 2023-02-15 10:30:41 +01:00
blufi.rst fix blufi doc error 2023-05-17 04:06:11 +00:00
bootloader.rst Merge branch 'docs/update_cn_trans_api_guides' into 'release/v5.1' 2023-04-25 17:16:43 +08:00
build-system.rst build-system: replace ADDITIONAL_MAKE_CLEAN_FILES with ADDITIONAL_CLEAN_FILES 2023-05-10 09:53:55 +08:00
coexist.rst feat(docs) Add RF Coexist docs for H2 2023-11-22 17:04:55 +08:00
core_dump_internals.rst docs: provide CN translation for api-guides/core_dump.rst and api-guides/core_dump_internals.rst (Backport v5.1) 2023-09-05 14:44:29 +08:00
core_dump.rst docs: provide CN translation for api-guides/core_dump.rst and api-guides/core_dump_internals.rst (Backport v5.1) 2023-09-05 14:44:29 +08:00
cplusplus.rst docs: provide CN translation for api-guides/cplusplus.rst (backport v5.1) 2023-09-07 13:15:27 +08:00
deep-sleep-stub.rst docs: add wake stub example link to deep-sleep-stub.rst 2023-01-10 17:03:54 +08:00
dfu.rst docs: Sync up CN and EN versions for files in api-guides and hw-reference (Jan) 2023-01-18 18:57:59 +08:00
error-handling.rst docs: add C++ support chapter to the API guides 2022-11-04 18:37:03 +01:00
esp-wifi-mesh.rst docs: remove duplicate "the" articles 2022-10-05 11:58:23 +02:00
external-ram.rst doc: update s3 psram vaddr max range size 2023-08-23 19:10:58 +08:00
fatal-errors.rst docs: update fatal error doc for C6/H2 2023-01-29 14:03:09 +08:00
flash_psram_config.rst docs: update s3 flash psram speed configuration programming guide 2023-04-03 10:30:50 +08:00
general-notes.rst docs:update CN translation for startup and debugging-example 2021-06-08 11:18:27 +08:00
hardware-abstraction.rst docs: provide CN tranlsation for api-guides/hardware-abstraction.rst 2023-07-28 14:42:03 +08:00
hlinterrupts.rst docs: provide CN translation for three short docs of api-guides (backport v5.1) 2023-09-05 11:11:27 +08:00
host-apps.rst docs: fix rst external links with wrong format 2023-02-13 11:51:31 +08:00
index.rst ble docs: Update the ble docs for esp32c6 and esp32h2 2023-05-19 11:03:11 +08:00
linker-script-generation.rst Docs: update CN trans for several docs in api-guides 2022-08-10 18:55:39 +08:00
lwip.rst revert(lwip): Revert changes to LWIP task priority macro from MR 25020 (backport v5.1) 2023-10-17 14:39:39 +08:00
memory-types.rst docs: update misc docs for C6 and H2 2023-02-15 17:27:31 +08:00
openthread.rst provide CN translation for api-guides/openthread.rst (backport v5.1) 2023-08-23 19:09:07 +08:00
partition-tables.rst feat(doc): update wifi sections for H2 2023-09-21 14:28:12 +08:00
reproducible-builds.rst docs: add documentation about reproducible builds 2022-04-26 11:31:13 +02:00
RF_calibration.rst docs: provide CN translation for three short docs of api-guides (backport v5.1) 2023-09-05 11:11:27 +08:00
startup.rst docs: update misc docs for C6 and H2 2023-02-15 17:27:31 +08:00
SYSVIEW_FreeRTOS.txt freertos: Remove legacy data types 2022-02-09 23:05:45 +08:00
thread-local-storage.rst docs: provide CN translation for three short docs of api-guides (backport v5.1) 2023-09-05 11:11:27 +08:00
unit-tests.rst docs: Sync up CN and EN versions for files in api-guides and hw-reference (Jan) 2023-01-18 18:57:59 +08:00
usb-otg-console.rst docs: fix a typo in api-guides/usb-otg-console 2023-06-28 14:40:44 +08:00
usb-serial-jtag-console.rst docs: updated misc C6 programming guide docs with minor changes. 2023-05-31 15:47:26 +08:00
wifi-security.rst docs(wifi): Update wifi and wifi security documentation 2023-09-14 10:14:13 +08:00
wifi.rst docs(wifi): Update wifi and wifi security documentation 2023-09-14 10:14:13 +08:00
wireshark-user-guide.rst Added wireshark instruction to provide a common workflow for users submitting diagnostic data for Wi-Fi troubleshooting 2018-11-16 14:44:58 +08:00