qml: show untrusted text as plain text
What changed, and why it matters
This commit changes how the Monero wallet's user interface displays text that comes from outside sources. It switches several labels and dialogs from rich text (which can include formatting, links, or hidden instructions) to plain text, reducing the risk that an attacker could trick the wallet into showing a fake message or clickable link. It also replaces a system message dialog in the QR scanner with a custom one so scanned QR code data is not rendered as rich text. A new transaction-details popup is intentionally kept as rich text, but only for wallet-generated transaction summaries.
Treat this as a security-hardening fix and include it in the next release. Review any remaining QML text elements that still use AutoText or RichText with untrusted content, and ensure the new txDetailsPopup content is fully sanitized or generated only from trusted wallet data. Consider adding a code-review guideline requiring plain text for all user/remote-facing strings.
Security signals we found
Multiple QML text elements switched from AutoText/RichText-capable defaults to Text.PlainText
StandardDialog default textFormat changed from TextEdit.AutoText to TextEdit.PlainText
QR scanner MessageDialog removed; scanned data errors now shown through a controlled popup as plain text
Mining error strings stripped of HTML `<br>` tags in favor of plain-text newlines
New transaction-details dialog explicitly uses RichText, but content is wallet-generated, not user/remote input
Evidence from the diff
The patch sets textFormat: Text.PlainText on multiple QML Labels/Text items and changes StandardDialog default textFormat from TextEdit.AutoText to TextEdit.PlainText. AutoText in Qt Quick will interpret strings starting with HTML tags as rich text, which can enable HTML injection / fake UI content when untrusted input is displayed. Affected surfaces include password dialog instructions, QR scanner errors, standard dialogs, update availability text, and wallet file names in the wizard. The QR scanner now uses a custom informationPopup instead of MessageDialog for errors. Mining error messages remove <br> HTML tags and use plain newlines. A new txDetailsPopup (rich text) is added in main.qml for transaction details, replacing the generic informationPopup for that purpose.
Changed components
components/PasswordDialog.qmlcomponents/QRCodeScanner.qmlcomponents/StandardDialog.qmlcomponents/UpdateDialog.qmlmain.qmlpages/History.qmlpages/Mining.qmlwizard/WizardOpenWallet1.qmlInspect captured patch +41 / −27
### components/PasswordDialog.qml
@@ -156,6 +156,7 @@ FocusScope {
Layout.maximumWidth: 400
Label {
+ textFormat: Text.PlainText
text: {
if (newPasswordDialogMode) {
return qsTr("Please enter new wallet password") + translationManager.emptyString;
### components/QRCodeScanner.qml
@@ -29,7 +29,6 @@
import QtQuick
import QtCore
import QtMultimedia
-import QtQuick.Dialogs
import moneroComponents.QRCodeScanner 1.0
Rectangle {
@@ -83,11 +82,18 @@ Rectangle {
return { "address": address, "extra_parameters": params }
}
+ // Errors may contain scanned data; MessageDialog would render it as rich text
+ function showError(error) {
+ informationPopup.title = qsTr("QR Scanner") + translationManager.emptyString
+ informationPopup.text = error
+ informationPopup.onCloseCallback = null
+ informationPopup.open()
+ }
+
function showDecodeError(error, warning) {
if (!warning)
root.state = "Stopped"
- messageDialog.text = error
- messageDialog.visible = true
+ showError(error)
}
function startCapture() {
@@ -172,8 +178,7 @@ Rectangle {
console.error("QR scanner camera error:", error, errorString)
if (root.state === "Capture") {
root.state = "Stopped"
- messageDialog.text = errorString
- messageDialog.visible = true
+ root.showError(errorString)
}
}
focusMode: Camera.FocusModeAuto
@@ -231,14 +236,6 @@ Rectangle {
}
}
- MessageDialog {
- id: messageDialog
- title: qsTr("QR Scanner") + translationManager.emptyString
- onAccepted: {
- root.state = "Stopped"
- }
- }
-
Connections {
target: cameraPermission
function onStatusChanged() {
### components/StandardDialog.qml
@@ -46,6 +46,8 @@ Rectangle {
property alias okText: okButton.text
property alias cancelText: cancelButton.text
property alias closeVisible: closeButton.visible
+ // Set at declaration only; changing it at runtime reformats the content
+ property alias textFormat: dialogContent.textFormat
// same signals as Dialog has
signal accepted()
@@ -136,7 +138,7 @@ Rectangle {
Layout.fillHeight: true
renderType: Text.QtRendering
font.family: MoneroComponents.Style.fontLight.name
- textFormat: TextEdit.AutoText
+ textFormat: TextEdit.PlainText
readOnly: true
font.pixelSize: 14
selectByMouse: false
### components/UpdateDialog.qml
@@ -75,6 +75,7 @@ Popup {
font.family: MoneroComponents.Style.fontRegular.name
font.pixelSize: 18
text: qsTr("New Monero version v%1 is available.").arg(updateDialog.version)
+ textFormat: Text.PlainText
}
Text {
### main.qml
@@ -1835,6 +1835,15 @@ ApplicationWindow {
}
}
+ // Transaction details dialog
+ StandardDialog {
+ id: txDetailsPopup
+ anchors.fill: parent
+ z: parent.z + 1
+ cancelVisible: false
+ textFormat: TextEdit.RichText
+ }
+
// Transaction confirmation popup
TxConfirmationDialog {
// dynamically change onclose handler
@@ -1977,9 +1986,9 @@ ApplicationWindow {
informationPopup.open();
}
onRejectedNewPassword: {}
- Keys.enabled: !passwordDialog.visible && informationPopup.visible
- Keys.onEnterPressed: informationPopup.close()
- Keys.onReturnPressed: informationPopup.close()
+ Keys.enabled: !passwordDialog.visible && (informationPopup.visible || txDetailsPopup.visible)
+ Keys.onEnterPressed: informationPopup.visible ? informationPopup.close() : txDetailsPopup.close()
+ Keys.onReturnPressed: informationPopup.visible ? informationPopup.close() : txDetailsPopup.close()
}
DevicePassphraseDialog {
@@ -2503,6 +2512,7 @@ ApplicationWindow {
var inputDialogVisible = inputDialog && inputDialog.visible
var successfulTxPopupVisible = successfulTxPopup && successfulTxPopup.visible
var informationPopupVisible = informationPopup && informationPopup.visible
+ var txDetailsPopupVisible = txDetailsPopup && txDetailsPopup.visible
// prompt password after X seconds of inactivity
var inactivity = Utils.epoch() - appWindow.userLastActive;
@@ -2511,6 +2521,7 @@ ApplicationWindow {
if (inputDialogVisible) inputDialog.close()
remoteNodeDialog.close();
informationPopup.close()
+ txDetailsPopup.close()
if (txConfirmationPopup.visible) {
txConfirmationPopup.close()
txConfirmationPopup.clearFields()
@@ -2530,6 +2541,7 @@ ApplicationWindow {
if (inputDialogVisible) inputDialog.open(inputDialog.inputText)
if (successfulTxPopupVisible) successfulTxPopup.open(successfulTxPopup.transactionID)
if (informationPopupVisible) informationPopup.open()
+ if (txDetailsPopupVisible) txDetailsPopup.open()
} else {
passwordDialog.showError(qsTr("Wrong password"));
}
### pages/History.qml
@@ -1758,10 +1758,9 @@ Rectangle {
rings = rings.replace(/\|/g, '\n')
currentWallet.getTxKeyAsync(hash, function(hash, tx_key) {
- informationPopup.title = qsTr("Transaction details") + translationManager.emptyString;
- informationPopup.content = buildTxDetailsString(hash, hasPaymentId ? paymentId : null, tx_key, tx_note, destinations, rings, address, address_label, integratedAddress, dateTime, amount);
- informationPopup.onCloseCallback = null
- informationPopup.open();
+ txDetailsPopup.title = qsTr("Transaction details") + translationManager.emptyString;
+ txDetailsPopup.content = buildTxDetailsString(hash, hasPaymentId ? paymentId : null, tx_key, tx_note, destinations, rings, address, address_label, integratedAddress, dateTime, amount);
+ txDetailsPopup.open();
});
}
### pages/Mining.qml
@@ -326,12 +326,12 @@ Rectangle {
}
else
{
- miningError(qsTr("Couldn't start mining.<br>") + translationManager.emptyString)
+ miningError(qsTr("Couldn't start mining.") + translationManager.emptyString)
}
}
}
else {
- miningError(qsTr("Couldn't start mining.<br>") + translationManager.emptyString)
+ miningError(qsTr("Couldn't start mining.") + translationManager.emptyString)
}
}
}
@@ -582,9 +582,10 @@ Rectangle {
function miningError(message) {
p2poolManager.exit()
errorPopup.title = qsTr("Error starting mining") + translationManager.emptyString;
- errorPopup.text = message
+ var text = message
if (persistentSettings.useRemoteNode && !persistentSettings.allowRemoteNodeMining)
- errorPopup.text += qsTr("Mining is only available on local daemons. Run a local daemon to be able to mine.<br>") + translationManager.emptyString
+ text += "\n" + qsTr("Mining is only available on local daemons. Run a local daemon to be able to mine.") + translationManager.emptyString
+ errorPopup.text = text
errorPopup.open()
}
@@ -635,7 +636,7 @@ allArgs = allArgs.filter( ( el ) => !defaultArgs.includes( el.split(" ")[0] ) )
startP2Pool()
}
else {
- miningError(qsTr("Couldn't start mining.<br>") + translationManager.emptyString)
+ miningError(qsTr("Couldn't start mining.") + translationManager.emptyString)
}
}
@@ -655,7 +656,7 @@ allArgs = allArgs.filter( ( el ) => !defaultArgs.includes( el.split(" ")[0] ) )
update()
}
else {
- miningError(qsTr("Couldn't start mining.<br>") + translationManager.emptyString)
+ miningError(qsTr("Couldn't start mining.") + translationManager.emptyString)
}
}
### wizard/WizardOpenWallet1.qml
@@ -254,6 +254,7 @@ Rectangle {
}
Text {
+ textFormat: Text.PlainText
text: {
// truncate on window width
var maxLength = wizardController.layoutScale <= 1 ? 12 : 16Why this scored 65/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.