Is my XDebug secure using Vscode SSH and the vscode-php-debug by Felix Becker?
PHP version: 7.3.32 Xdebug version: v3.1.1 VS Code extension version: v1.22.0
Your launch.json: Xdebug php.ini config: { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Listen for Xdebug", "type": "php", "request": "launch", "port": 9003, "pathMappings": { "/var/www/html":"${workspaceFolder}" }
}
]
}
Xdebug logfile (from setting xdebug.log in php.ini):
VS Code extension logfile (from setting "log": true in launch.json):
debugging is working so I am not going to post the log file.
Code snippet to reproduce:
My question is, if my debugger is installed for SSH in vscode does the SSH tunnel automatically get created? While debugging works, but I am trying to verify that using xdebug is secure.
I'm not sure I understand the question. You are asking about port forwarding. This extension does not setup any port forwarding, but vscode could do that automatically. I think it can be configured under Features/Remote/Auto Forward Ports. I think you can get a port forward from your workstation to the server, so somebody on your PC can connect to this extensions port listening for debug connections. Under normal circumstances, I don't think you are exposing anything here.
On the other hand having Xdebug installed on a productions server could pose a risk if it's configured to connect back to the client and having triggers enabled without some secret key...
It all very much depends on your situation and setup...
I have been reading the VSCode documentation a bit more.
"remote.extensionKind": { "ms-azuretools.vscode-docker": [ "ui" ], "msjsdiag.debugger-for-chrome": [ "workspace" ] }
If I set the felixbecker.php-debug: ["ui"] then it stops working, but if felixbecker.php-debug: ["workspace"] is set then it works remotely.
Reading more from this document: https://code.visualstudio.com/docs/remote/ssh#_debugging-on-the-ssh-host The debugger is run on the remote host.
Still I cannot see the traffic using tcpdump.
Does anyone have any suggestions?
Ok, now I know you are talking about VSCode Remote - SSH. Yes, extensions can be run on the UI side (the workstation) or the workspace side (SSH server). The natural option here is to run it on the server. I have not tried to run it on UI, it would probably not make sense, since you want the debugger to be close to the files being executed.
Regarding network traffic.
If you are referring to the DBGP protocol traffice, it is happening between your PHP process and the debug extension. Perhaps you can sniff the "lo" interface on port 9003.
However you can also see all the messages if you add log: true into your launch.json or perhaps addind xdebug.log to your php.ini (https://xdebug.org/docs/all_settings#log).
I had a talk about debugging with Xdebug and VS Code where I also explained a lot of these concepts. Maybe you can gather something from there: https://damjan.cvetko.org/blog/2021-10-01-interactive-debugging-php/
Let me know if you have specific questions and I'll try to answer them.
Thank you @zobo for sharing your blog post. I too have been using xdebug for many years. It is very important to me when developing.
Also I have now finally gotten the traffic.
tcpdump -vv -nn -i any dst port 9003
I found the tcpdump command here: https://popovserhii.com/debug-your-php-code-on-remote-linux-server-using-phpstorm-and-xdebug-with-its-port-forwarding-through-ssh
I think that since I am using VSCode Remote it opens on listens on lo interface like you mentioned above. Though the tcpdump actually reports my docker gateway IP.
I think this is the same as lo, but I cannot yet prove this. Any ideas?