فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(security): exercise malicious invoice ID, type and date in installed WebView2
davoodmehraban89 committed
Oct 31, 2026 at 00:23 UTC
735378911237c5b5b3cda5b933c381c5d6c8fd68
1 file changed
+36
tests/windows-vm-ui-interaction-audit-browser.js
+36
@@ -378,7 +378,43 @@
378
delete window.Q01_EXPENSE_ID_ATTACK;
379
delete window.Q01_EXPENSE_HTML_ATTACK;
380
}
381
+ // Read-only adversarial invoice render: unknown imported kinds, invoice IDs,
382
+ // number and date must never create active markup or execute row handlers.
383
+ const invoiceController=window.InvoiceController;
384
+ const invoiceView=window.InvoicesView;
385
+ const originalInvoices=invoiceController.getAll;
386
+ const originalEditInvoice=invoiceView.editInvoice;
387
+ const hostileInvoiceId="inv-test');window.Q01_INVOICE_ID_ATTACK=true;//";
388
+ const injectedKind='<img src=x onerror="window.Q01_INVOICE_HTML_ATTACK=true">';
389
+ let editedInvoiceId=null;
390
+ try {
391
+ invoiceController.getAll=async()=>[{id:hostileInvoiceId,number:injectedKind,
392
+ kind:injectedKind,contactName:injectedKind,date:injectedKind,
393
+ grandTotal:100,paidAmount:0,remaining:100,status:'unpaid',isPreInvoice:false}];
394
+ await invoiceView.reload();
395
+ const frag=document.createElement('div');
396
+ frag.innerHTML=invoiceView.renderTable();
397
+ if(frag.querySelector('img') || frag.querySelector('script') ||
398
+ !frag.textContent.includes(injectedKind)) {
399
+ throw Error('Imported invoice kind or date escaped the safe HTML rendering boundary');
400
+ }
401
+ invoiceView.editInvoice=(id)=>{editedInvoiceId=id;};
402
+ const edit=frag.querySelector('button[title="ویرایش"]');
403
+ if(!edit) throw Error('Synthetic invoice edit handler missing');
404
+ edit.click();
405
+ if(editedInvoiceId!==hostileInvoiceId || window.Q01_INVOICE_ID_ATTACK ||
406
+ window.Q01_INVOICE_HTML_ATTACK) {
407
+ throw Error('Imported invoice identifier executed unsafe inline action code');
408
+ }
409
+ } finally {
410
+ invoiceController.getAll=originalInvoices;
411
+ invoiceView.editInvoice=originalEditInvoice;
412
+ await invoiceView.reload();
413
+ delete window.Q01_INVOICE_ID_ATTACK;
414
+ delete window.Q01_INVOICE_HTML_ATTACK;
415
+ }
416
const modalKeyboard={roleAndLabel:true,nestedDialogIsolation:true,
417
+ importedInvoiceHtmlEscaped:true,
418
expenseUnsafeHtmlEscaped:true,
419
modalFormLabelsLinked:true,
420
confirmationTextEscaped:true,visibleInputAutoFocused:true,