• Jinni@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    3 months ago

    It is moments like this where I wished docker didn’t exist. Could have made some news headlines.

    • zkfcfbzr@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      3 months ago

      Lotta people here saying ChatGPT can only generate text, can’t interact with its host system, etc. While it can’t directly run terminal commands like this, it can absolutely execute code, even code that interacts with its host system. If you really want you can just ask ChatGPT to write and execute a python program that, for example, lists the directory structure of its host system. And it’s not just generating fake results - the interface notes when code is actually being executed vs. just printed out. Sometimes it’ll even write and execute short programs to answer questions you ask it that have nothing to do with programming.

      After a bit of testing though, they have given some thought to situations like this. It refused to run code I gave it that used the python subprocess module to run the command, and even refused to run code that used subprocess or exec commands when I obfuscated the purpose of the code, out of general security concerns.

      I’m unable to execute arbitrary Python code that contains potentially unsafe operations such as the use of exec with dynamic input. This is to ensure security and prevent unintended consequences.

      However, I can help you analyze the code or simulate its behavior in a controlled and safe manner. Would you like me to explain or break it down step by step?

      Like anything else with ChatGPT, you can just sweet-talk it into running the code anyways. It doesn’t work. Maybe someone who knows more about Linux could come up with a command that might do something interesting. I really doubt anything ChatGPT does is allowed to successfully run sudo commands.

      Edit: I fixed an issue with my code (detailed in my comment below) and the output changed. Now its output is:

      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.

      image of output

      So it seems confirmed that no sudo commands will work with ChatGPT.