Skip to content

Running sudo cmd in extension fails in VSCode Insiders ("no new privileges") #160380

Closed

Description

@ttywork

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

  1. jrieken commented on Sep 8, 2022

    @jrieken
    Contributor

    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?

  2. added
    info-needed
    on Sep 8, 2022
  3. linux4life798 commented on Sep 8, 2022

    @linux4life798

    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.

    Also how do you run VS Code?

    It was installed using the normal Microsoft insiders debian package to root. It was launched graphically through Gnome using the normal code-insiders.desktop.

    Can you run sudo in VS Code's terminal?

    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:

    hesling@funtop:~/chromiumos$ sudo ls
    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.
    hesling@funtop:~/chromiumos$ 
     *  History restored 
    
    hesling@funtop:~/chromiumos$ sudo echo hi
    hi
    hesling@funtop:~/chromiumos$ 
    
  4. ttywork commented on Sep 9, 2022

    @ttywork
    Author

    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 tried setpriv -d in the extension and in the terminal. The command prints no_new_privs: 1 in the extension, and no_new_privs: 0 in the terminal.

    Please let me know if you need any more information to debug this issue.

  5. deepak1556 commented on Sep 9, 2022

    @deepak1556
    Collaborator

    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.fork whereas with Insiders the process is created as a Chromium utility process. Now for the actual bug, all chromium child processes on linux get launched with PR_SET_NO_NEW_PRIVS bit 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.

  6. added
    bug
    extension-host
    confirmed
    sandbox
    and removed
    info-needed
    on Sep 9, 2022
  7. added
    unreleased
    insiders-released
    and removed
    unreleased
    on Sep 16, 2022
  8. added
    author-verification-requested
    on Sep 29, 2022
  9. vscodenpa commented on Sep 29, 2022

    @vscodenpa

    This bug has been fixed in the latest release of VS Code Insiders!

    ttywork, you can help us out by commenting /verified if 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: About in the command palette to check), and leave a comment letting us know what isn't working as expected.

    Happy Coding!

  10. ttywork commented on Oct 3, 2022

    @ttywork
    Author

    /verified

  11. removed
    author-verification-requested
    on Oct 3, 2022
  12. locked and limited conversation to collaborators on Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugconfirmedextension-hostinsiders-releasedsandboxverified

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions