Access denied when enabling or setting by default a theme (on Nginx)
I've got a solution after several hours working on it.

I am using Nginx instead of Apache and I did not configure it to add the query string in the rewriting to index.php. So neither the token nor the theme parameters were reaching the script and system_theme_enable()/system_theme_default() (located in /modules/system/system.admin.inc) always returned MENU_ACCESS_DENIED, which I consider to be a very confusing behavior by the way.

This is how the server config looks like now and makes it work:

location / {
    try_files $uri $uri/ /index.php?$query_string;
}