Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(xss): escape token names, tiers and error text before they reach innerHTML
nirholasae2abb52a9cd
diff --git a/pages/home.html b/pages/home.htmlindex e832dd744..d9b0a624a 100644--- a/pages/home.html+++ b/pages/home.html@@ -3599,7 +3599,8 @@ import { attendRotation } from '/src/shared/attended-rotation.js';const PIL_COLOR = { pedigree: '#5fe3ff', structure: '#34d399', narrative: '#a07bff', momentum: '#fbbf24' };const TIER_LABEL = { prime: 'PRIME', strong: 'STRONG', lean: 'LEAN', watch: 'WATCH', avoid: 'AVOID' };- const tc = (t) => `t-${t || 'watch'}`;+ const tc = (t) => `t-${TIER_LABEL[t] ? t : 'watch'}`;+ const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);function miniCard(it) {const tier = it.tier || 'watch';@@ -3618,11 +3619,11 @@ import { attendRotation } from '/src/shared/attended-rotation.js';a.innerHTML = `<div class="hoc-score ${tc(tier)}">${score}</div><div class="hoc-info">- <div class="hoc-sym">$${sym}</div>- <div class="hoc-name">${name}</div>+ <div class="hoc-sym">$${esc(sym)}</div>+ <div class="hoc-name">${esc(name)}</div><div class="hoc-pillars">${bars}</div></div>- <span class="hoc-tier ${tc(tier)}">${TIER_LABEL[tier] || tier.toUpperCase()}</span>`;+ <span class="hoc-tier ${tc(tier)}">${esc(TIER_LABEL[tier] || String(tier).toUpperCase())}</span>`;return a;}diff --git a/public/discover/detail.js b/public/discover/detail.jsindex bb87caade..47aa88702 100644--- a/public/discover/detail.js+++ b/public/discover/detail.js@@ -300,7 +300,7 @@ function buildEmbedPanel(item, $) {{label: 'iframe',key: 'iframe',- value: `<iframe src="${embedUrl}" width="480" height="600" style="border:0;border-radius:12px" allow="autoplay; xr-spatial-tracking" sandbox="allow-scripts allow-same-origin allow-popups" title="${name}"></iframe>`,+ value: `<iframe src="${embedUrl}" width="480" height="600" style="border:0;border-radius:12px" allow="autoplay; xr-spatial-tracking" sandbox="allow-scripts allow-same-origin allow-popups" title="${escapeHtml(name)}"></iframe>`,rows: 3,},{ label: 'Link', key: 'link', value: pageUrl, rows: 1 },@@ -325,7 +325,7 @@ function buildEmbedPanel(item, $) {{label: 'iframe',key: 'iframe',- value: `<iframe src="${origin}/app#model=${encodeURIComponent(item.glbUrl)}" width="480" height="600" style="border:0;border-radius:12px" allow="autoplay; xr-spatial-tracking" title="${name}"></iframe>`,+ value: `<iframe src="${origin}/app#model=${encodeURIComponent(item.glbUrl)}" width="480" height="600" style="border:0;border-radius:12px" allow="autoplay; xr-spatial-tracking" title="${escapeHtml(name)}"></iframe>`,rows: 3,},{ label: 'Link', key: 'link', value: detailUrl, rows: 1 },diff --git a/src/create-prompt.js b/src/create-prompt.jsindex 800cb5e99..184975e5d 100644--- a/src/create-prompt.js+++ b/src/create-prompt.js@@ -15,6 +15,7 @@*/import { log } from './shared/log.js';+import { escapeHtml } from './shared/coin-format.js';import { injectFestivePresets } from './shared/festive-presets.js';import { mountPromptDictation } from './voice/prompt-dictation.js';import { captureWizardReturn, pendingWizardReturn, clearWizardReturn, wizardReturnUrl } from './shared/wizard-return.js';@@ -557,7 +558,7 @@ function failBuild(err) {const retryable = !(err instanceof ApiError) || err.retryable !== false;setError(buildError,- `<span>${message}</span>` ++ `<span>${escapeHtml(message)}</span>` +(retryable? ` <button type="button" id="build-retry-now" class="cancel-build" style="margin-left:10px">Try again</button>`: '') +diff --git a/src/forge-conversational-refine.js b/src/forge-conversational-refine.jsindex 428fff97d..a0030aeac 100644--- a/src/forge-conversational-refine.js+++ b/src/forge-conversational-refine.js@@ -19,6 +19,8 @@// forwards the same x-forge-client identity forge.js uses so an iteration// lands in the same anonymous gallery/lineage as its parent.+import { escapeHtml } from './shared/coin-format.js';+const POLL_INTERVAL_MS = 2500;const MAX_POLL_MS = 5 * 60 * 1000;@@ -127,7 +129,7 @@ if (actions && resultBar && viewer) {lineageHost.innerHTML = lineage.map((v, i) => {const label = i === 0 ? 'Original' : v.instruction || `v${i + 1}`;- return `<button type="button" class="iterate-version${i === activeIndex ? ' is-active' : ''}" data-index="${i}" title="${label}">${i === 0 ? 'v0' : `v${i}`}</button>`;+ return `<button type="button" class="iterate-version${i === activeIndex ? ' is-active' : ''}" data-index="${i}" title="${escapeHtml(label)}">${i === 0 ? 'v0' : `v${i}`}</button>`;}).join('');lineageHost.querySelectorAll('.iterate-version').forEach((b) => {diff --git a/src/shared/trade-receipt-view.js b/src/shared/trade-receipt-view.jsindex bfec4be15..d755c0842 100644--- a/src/shared/trade-receipt-view.js+++ b/src/shared/trade-receipt-view.js@@ -12,6 +12,7 @@*/import { escapeHtml as esc } from '../trader-format.js';+import { safeUrl } from '../safe-url.js';const TIMING_LABEL = {before_entry: 'before entry',@@ -82,8 +83,11 @@ function statusTone(status) {}function link(href, label) {- if (!href) return '';- return `<a class="rc-link" href="${esc(href)}" target="_blank" rel="noopener noreferrer">${esc(label)} <span aria-hidden="true">↗</span></a>`;+ // Evidence links can carry a third-party feed's URL (a scout's news source),+ // so only http(s) and site paths ever become a clickable href.+ const safe = safeUrl(href, '');+ if (!safe) return '';+ return `<a class="rc-link" href="${esc(safe)}" target="_blank" rel="noopener noreferrer">${esc(label)} <span aria-hidden="true">↗</span></a>`;}function card(title, whenHtml, body) {diff --git a/tests/trade-receipt-view-links.test.js b/tests/trade-receipt-view-links.test.jsnew file mode 100644index 000000000..2e1ae7e18--- /dev/null+++ b/tests/trade-receipt-view-links.test.js@@ -0,0 +1,33 @@+import { describe, it, expect } from 'vitest';++import { receiptHTML } from '../src/shared/trade-receipt-view.js';++function receipt(source) {+ return {+ summary: 'Bought on a scout flag.',+ trigger: { label: 'Scout', detail: null },+ position: { opened_at: '2026-10-01T00:00:00Z', paper: false, share_url: null, token_url: null },+ legs: [],+ evidence: {+ scout: {+ score: 70,+ timing: 'before_entry',+ at: '2026-09-30T23:59:00Z',+ evidence: [{ type: 'news_match', platform: null, detail: 'Covered by a news feed', source }],+ },+ },+ };+}++describe('trade receipt evidence links', () => {+ it('renders an http(s) source as a link', () => {+ const html = receiptHTML(receipt('https://news.example/story'), { showLinks: false });+ expect(html).toContain('href="https://news.example/story"');+ });++ it('drops a script-scheme source instead of rendering it clickable', () => {+ const html = receiptHTML(receipt('javascript:alert(document.domain)'), { showLinks: false });+ expect(html).not.toContain('javascript:');+ expect(html).toContain('Covered by a news feed');+ });+});