The issue of arbitrary code access and execution
-
Here’s another one to toss out to consider, which is the problem of code being directly accessed and executed, often in things like plug ins and themes (a recurring security nightmare).
One of the things that made wordpress easy to extend is that coding a theme or a plugin isn’t really that hard – and that these features have full access to “all the toys” as it were without very much control from the core itself. The results are often things like XXS issues, upload plugins that have security leaks and let people upload anything, anywhere, and so on. While most of the security problems are blamed on poor coding or errors made in the process, I think there is perhaps a bigger issue: too many files that can just be called and executed, and that can do too much without dealing with the core.
I mentioned a while back that I think wordpress needs to move to a more strict API model. I would like to take it one step further, which is to make it so that theme and plugin code is effectively useless without being run by a core handler.
In practical terms, it would mean that while a plug in might allow you to upload files, the actual upload should be handled in core and properly sanitized and security checked for the protection of the entire installation. So it a poorly written plugin allows someone to upload a.jpg.php file that would be executable, the core would see it and disallow the upload.
People attempting to access to code directly to force an upload would be stymied because the plugin itself doesn’t actually do the work – it still needs the core. Basically, no function that accesses data, saves or modifies files, databases, or otherwise does anything within wordpress should be handled in the core, and not as a tack on / plug in.
I would further say it might be time to have things like sliders, genericons, and whatever classes as either plugins or perhaps a new class called “helpers”, added to an installation ONCE and called by themes or plugins that need to use them. One of the true disasters of the recent slider security issue is how many themes had the slider, and that it could be arbitrarily executed even if the theme was not active. Properly squashing that bug involved making sure that any unused themes were deleted from every install. The problem of themes not maintained is a real pain when it comes to common code like this. Again, for security purposes, it might be good to have ways to call these helpers via core, so that their operations could be controlled.
It’s just a think out loud thing. One suggestion would be to use an encoder / decoder (even base64 or whatever) to make it so that plugins and such can only be exectute by a core controller, rendering them useless to access directly. However, I think that the system load to do this versus the security might not be worth it.
The topic ‘The issue of arbitrary code access and execution’ is closed to new replies.