Summary
A low privilege user account with page edit privilege can read any server files using Twig Syntax. Thjis includes Grav user account files - /grav/user/accounts/*.yaml. This file stores hashed user password, 2FA secret, and the password reset token. This can allow an adversary to compromise any registered account by resetting a password for a user to get access to the password reset token from the file or by cracking the hashed password.
Proof Of Concept
{{ read_file('/var/www/html/grav/user/accounts/riri.yaml') }}
Use the above Twig template syntax in a page and observe that the administrator riri's authentication details are exposed accessible by any unauthenticated user.
![file-read-2-ATO](https://private-user-images.githubusercontent.com/48800246/327993724-9dee4daa-f029-40dd-9646-94c794d3f254.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk4OTUwNTMsIm5iZiI6MTcxOTg5NDc1MywicGF0aCI6Ii80ODgwMDI0Ni8zMjc5OTM3MjQtOWRlZTRkYWEtZjAyOS00MGRkLTk2NDYtOTRjNzk0ZDNmMjU0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzAyVDA0MzIzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTEwODFiMjY2YTZlZWNiOWExYTg0ZDExYWVjMWU0YTA0NGE2MDBkZmRjM2E3NTYxMmNlNGMzOGRmODE0MDI2MjAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.lL8Vq9W8x5sNyEuIAWS6JcSYH8FBYAwbXiDO1v9yX58)
As an additional proof of concept for reading system files, observe the /etc/passwd
file read using the following Twig syntax:
{{ read_file('/etc/passwd') }}
![file-read-etc-passwd](https://private-user-images.githubusercontent.com/48800246/327993826-e45de4d4-f81f-42cf-8466-aa36b225ca94.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk4OTUwNTMsIm5iZiI6MTcxOTg5NDc1MywicGF0aCI6Ii80ODgwMDI0Ni8zMjc5OTM4MjYtZTQ1ZGU0ZDQtZjgxZi00MmNmLTg0NjYtYWEzNmIyMjVjYTk0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzAyVDA0MzIzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM1OGZlOGIwYzgzZWVjYzYzMjUyMjE1ZmEyNTQ1MWMyOGU5YmQzNmUwMGI0N2JjMjdkNzlhNTEyMzNjYmNjZTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.LJ8_9FAub5WRxTPN-QWAcVZABb5n22NYnqIzHFVeFLc)
Impact
This can allow a low privileged user to perform a full account takeover of other registered users including Adminsitrators. This can also allow an adversary to read any file in the web server.
Summary
A low privilege user account with page edit privilege can read any server files using Twig Syntax. Thjis includes Grav user account files - /grav/user/accounts/*.yaml. This file stores hashed user password, 2FA secret, and the password reset token. This can allow an adversary to compromise any registered account by resetting a password for a user to get access to the password reset token from the file or by cracking the hashed password.
Proof Of Concept
{{ read_file('/var/www/html/grav/user/accounts/riri.yaml') }}
Use the above Twig template syntax in a page and observe that the administrator riri's authentication details are exposed accessible by any unauthenticated user.
As an additional proof of concept for reading system files, observe the
/etc/passwd
file read using the following Twig syntax:{{ read_file('/etc/passwd') }}
Impact
This can allow a low privileged user to perform a full account takeover of other registered users including Adminsitrators. This can also allow an adversary to read any file in the web server.