Good day,
I’m trying to create a docker environment where one can exercise stored XSS.
The XSS happens in the comment section and sends the document.cookie content to the attacker. The login cookie is not sent. That is only possible if HTTPOnly tag in the cookie is set to false.
Here’s my docker-compose file
version: "3.8"
services:
wordpress:
image: wordpress:4.1
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: dbuser
WORDPRESS_DB_PASSWORD: dbpassword
WORDPRESS_DB_NAME: exampledb
links:
- db:mysql
volumes:
- ./wordpress:/var/www/html
ports:
- 8080:80
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: dbuser
MYSQL_PASSWORD: dbpassword
MYSQL_RANDOM_ROOT_PASSWORD: '1'
ports:
- 3306:3306
volumes:
- ./db:/var/lib/mysql
volumes:
wordpress:
db:
I tried the following:
in wp-config.php
@ini_set('session.cookie_httponly', false);
@ini_set('session.cookie_secure', false);
@ini_set('session.use_only_cookies', false);
modifying the setcookie function in wp-login.php in all occurences (setting the httponly parameter to false)
setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), false );
without any success.
I appreciate any help possible.
2
Answers
You should edit ‘wp-includes/pluggable.php’ file. Change last true parameter to false.
Enable HttpOnly:
Disable HttpOnly:
I had a similar issue a while ago, and wordpress being wordpress caused it to be a bit of a nightmare, especially with other plugins also acting like they have free reign to change whatever they want on the box
This was the class I ended up using for messing around with cookies as wp was setting them, with hooks for login and auth cookies
that being said, if you just want to change those headers and you are running apache just bind-mount/find another way of getting a .htaccess into your docker machine and write a regex to strip it, I have used itto increase security but i imagine it would work in reverse as well, if this turns it on
something like this could be used to turn it off by dropping everything after the first ‘;’