Repository navigation
Description
Type: Bug
Steps to Reproduce:
Run sudo pwd (or any other command using sudo) via child_process.spawn in an extension.
I'm a contributor to CrOS IDE extension (https://source.chromium.org/chromium/chromium/src/+/main:third_party/chromite/ide_tooling/cros-ide/ - not published in the marketplace yet). Our extension relies on running some commands with sudo via child_process.spawn. We discovered that in recent Insiders edition (1.72.0-insider) running sudo fails with the following error message:
sudo: The "no new privileges" flag is set, which prevents sudo from running as root.
sudo: If sudo is running in a container, you may need to adjust the container configuration to disable the flag.
This affects any command run with sudo. This issue may be related to #154006
VS Code version: Code - Insiders 1.72.0-insider (daf5eb2, 2022-09-06T10:34:01.377Z)
OS version: Linux x64 5.18.16-1rodete1-amd64
Modes:
Sandboxed: Yes
System Info
| Item | Value |
|---|---|
| CPUs | Intel(R) Xeon(R) Gold 6154 CPU @ 3.00GHz (72 x 1200) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: disabled_off direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_renderer: enabled_on video_decode: disabled_software video_encode: disabled_software vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: disabled_off |
| Load (avg) | 1, 1, 1 |
| Memory (System) | 187.51GB (177.12GB free) |
| Process Argv | --crash-reporter-id 15b2b561-7f45-43c3-9d3d-dd095591b05c |
| Screen Reader | no |
| VM | 0% |
| DESKTOP_SESSION | cinnamon |
| XDG_CURRENT_DESKTOP | X-Cinnamon |
| XDG_SESSION_DESKTOP | cinnamon |
| XDG_SESSION_TYPE | x11 |
Extensions (5)
| Extension | Author (truncated) | Version |
|---|---|---|
| tsl-problem-matcher | amo | 0.6.2 |
| vscode-eslint | dba | 2.2.6 |
| prettier-vscode | esb | 9.8.0 |
| cros-ide | Goo | 0.0.14 |
| vscode-clangd | llv | 0.1.21 |
A/B Experiments
vsliv695:30137379
vsins829:30139715
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30422396
pythontb:30258533
pythonptprofiler:30281269
vshan820:30294714
pythondataviewer:30285072
vscod805cf:30301675
bridge0708:30335490
bridge0723:30353136
cmake_vspar411cf:30557515
vsaa593:30376534
pythonvs932:30404738
cppdebug:30492333
pylanb8912:30522163
vsclangdf:30492506
c4g48928:30535728
dsvsc012cf:30540253
pylantcb52cf:30558419
Activity
jrieken commentedon Sep 8, 2022
Looping in Robo (@deepak1556) but I don't believe this has anything to do with VS Code. ttywork Is the "no new privileges" a process or container process? Also how do you run VS Code? Can you run sudo in VS Code's terminal?
linux4life798 commentedon Sep 8, 2022
I'll let ttywork comment on
Is the "no new privileges" a process or container process?, but I can try to answer the other questions.It was installed using the normal Microsoft insiders debian package to root. It was launched graphically through Gnome using the normal
code-insiders.desktop.At the time/version ttywork reported this issue, I was able to run sudo in the interactive terminal. Later that day, I received the sudo "no new privileges" error on the interactive terminal. Today, sudo seems to be functional at the interactive terminal again. I may have upgraded between these events.
Evidence:
ttywork commentedon Sep 9, 2022
I am not aware of any use of containers (do you mean Docker?). We have a VS Code extension that runs Linux commands using Node’s
child_process.spawn. If the command that we run uses sudo, for example,sudo pwd, then we get an error in Insiders (but not in the stable VSCode). Unlike @linux4life798, I can use sudo in the terminal. I also triedsetpriv -din the extension and in the terminal. The command printsno_new_privs: 1in the extension, andno_new_privs: 0in the terminal.Please let me know if you need any more information to debug this issue.
deepak1556 commentedon Sep 9, 2022
Thanks for the context ttywork , I might know what the underlying issue is. Currently in Insiders we have been exploring a new process architecture for the Extension host which has not been rolled out to Stable yet. In Stable, the extension host is basically a forked process from the Chromium browser process using
child_process.forkwhereas with Insiders the process is created as a Chromium utility process. Now for the actual bug, all chromium child processes on linux get launched withPR_SET_NO_NEW_PRIVSbit set https://source.chromium.org/chromium/chromium/src/+/main:base/process/launch.h;l=208-210, although Electron has a patch to disable this for renderers which are not sandboxed and the terminal process is actually forked from one such process hence it was able to launch with sudo. I will disable this for the extension host which should resolve the issue.Also, #154006 only enabled the renderer sandbox and the extension host utility process gets launched with equivalent of
--no-sandbox.vscodenpa commentedon Sep 29, 2022
This bug has been fixed in the latest release of VS Code Insiders!
ttywork, you can help us out by commenting
/verifiedif things are now working as expected.If things still don't seem right, please ensure you're on version 2c80125 of Insiders (today's or later - you can use
Help: Aboutin the command palette to check), and leave a comment letting us know what isn't working as expected.Happy Coding!
ttywork commentedon Oct 3, 2022
/verified