Keep stored text out of Vue templates
What changed, and why it matters
This commit changes how BTCPay Server handles text that is stored in web pages and later used by Vue.js. It adds 'v-pre' markers to tell Vue to leave certain pieces of text alone, and it stops reading a form's JSON configuration directly from a textarea that Vue also controls. The likely goal is to prevent Vue from accidentally treating stored data as a template, which could lead to script injection or data leakage if an attacker can control that stored text. However, the patch is small and does not by itself prove an exploitable vulnerability exists.
Review all locations where user- or admin-controlled text is rendered inside pages that also initialize Vue, and ensure v-pre or equivalent escaping is applied consistently. Audit the form editor and wallet label flows for any remaining paths where stored data can reach a Vue template context. Consider adding tests that verify stored payloads containing Vue template syntax (e.g., {{ }}) are not executed.
Security signals we found
v-pre directives added to prevent Vue from compiling stored text as templates
Form config moved from Vue-bound textarea value to server-rendered Safe.Json variable
asp-for replaced with explicit id/name to decouple server-side form field from Vue model binding
Changes are consistent with a defensive fix for stored text being interpreted as Vue template syntax
Evidence from the diff
The commit makes four related changes: (1) adds v-pre to a wallet navigation link label, (2) introduces an initialConfig JavaScript variable rendered server-side via Safe.Json and changes the form editor to read from that variable instead of the Vue-bound textarea, (3) adds v-pre to transaction label spans, and (4) adds v-pre to a validation span. The pattern suggests a defensive fix against Vue template injection / client-side XSS where attacker-controlled text stored in the DOM could be compiled as a Vue template. The use of Safe.Json is a server-side serialization safeguard. The patch is partial and mitigative rather than a complete remediation of a specific bug.
Changed components
BTCPayServer/Components/WalletNav/Default.cshtmlBTCPayServer/Plugins/Forms/Views/Modify.cshtmlBTCPayServer/Plugins/Wallets/Views/UIWallets/ReservedAddresses.cshtmlBTCPayServer/wwwroot/js/form-editor.jsInspect captured patch +8 / −6
### BTCPayServer/Components/WalletNav/Default.cshtml
@@ -2,7 +2,7 @@
@inject DisplayFormatter DisplayFormatter
@model BTCPayServer.Components.WalletNav.WalletNavViewModel
-<a asp-area="Wallets" asp-controller="UIWallets" asp-action="WalletTransactions" asp-route-walletId="@Model.WalletId" class="unobtrusive-link">
+<a asp-area="Wallets" asp-controller="UIWallets" asp-action="WalletTransactions" asp-route-walletId="@Model.WalletId" class="unobtrusive-link" v-pre>
<h2 class="my-1">@Model.Label</h2>
<div class="text-muted fw-semibold" data-sensitive>
@DisplayFormatter.Currency(Model.Balance, Model.Network.CryptoCode)
### BTCPayServer/Plugins/Forms/Views/Modify.cshtml
@@ -193,6 +193,9 @@
<script src="~/vendor/vue-sanitize-directive/vue-sanitize-directive.umd.min.js" asp-append-version="true"></script>
<script src="~/vendor/vue-sortable/sortable.min.js" asp-append-version="true"></script>
<script src="~/vendor/vue-sortable/vue-sortable.js" asp-append-version="true"></script>
+ <script>
+ var initialConfig = @Safe.Json(Model.FormConfig);
+ </script>
<script src="~/js/form-editor.js" asp-append-version="true"></script>
<partial name="_ValidationScriptsPartial" />
}
@@ -275,8 +278,8 @@
</div>
<div class="tab-pane fade" id="CodeTabPane" role="tabpanel" aria-labelledby="CodeTabButton" tabindex="0">
<label asp-for="FormConfig" class="form-label" data-required text-translate="true">Form JSON</label>
- <textarea asp-for="FormConfig" class="form-control font-monospace" style="font-size:.85rem" rows="21" cols="21" v-model="configJSON" v-on:change="updateFromJSON"></textarea>
- <span asp-validation-for="FormConfig" class="text-danger"></span>
+ <textarea id="FormConfig" name="FormConfig" class="form-control font-monospace" style="font-size:.85rem" rows="21" cols="21" v-model="configJSON" v-on:change="updateFromJSON"></textarea>
+ <span asp-validation-for="FormConfig" class="text-danger" v-pre></span>
</div>
</div>
</div>
### BTCPayServer/Plugins/Wallets/Views/UIWallets/ReservedAddresses.cshtml
@@ -52,7 +52,7 @@
<span class="d-flex flex-wrap gap-2 align-items-center" not-permission="@WalletPolicies.CanManageWalletTransactions">
@foreach (var label in address.Labels)
{
- <span class="transaction-label" style="--label-bg:@label.Color;--label-fg:@label.TextColor">
+ <span class="transaction-label" style="--label-bg:@label.Color;--label-fg:@label.TextColor" v-pre>
<span>@label.Text</span>
@if (!string.IsNullOrEmpty(label.Link))
{
### BTCPayServer/wwwroot/js/form-editor.js
@@ -6,8 +6,7 @@ document.addEventListener('DOMContentLoaded', () => {
console.error('Error deserializing form config:', err)
}
}
- const $config = document.getElementById('FormConfig')
- let config = parseConfig($config.value) || {}
+ let config = parseConfig(initialConfig) || {}
const specialFieldTypeOptions = ['fieldset', 'textarea', 'select', 'mirror']
const inputFieldTypeOptions = ['text', 'number', 'password', 'email', 'url', 'tel', 'date', 'datetime-local', 'color', 'checkbox', 'hidden']Why this scored 63/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.