An attacker can steal a GitHub token by exploiting a vulnerability in VSCode's webviews, allowing them to install malicious extensions and gain full code execution. The attack involves creating a Jupyter notebook with a payload that installs a local workspace extension, which can then be used to steal the token.