Compare commits

...
3 Commits
Author SHA1 Message Date
hermes 11f56cc54a refactor(deploy): remove vestigial client credential fields
Build / Build-and-ng-test (pull_request) Successful in 5m25s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m57s
Build / Build-and-test-development (pull_request) Successful in 24m44s
The deploy client_id/client_secret fields were only read from localStorage
and never used by the manual or automatic deploy flows. Remove the dead
code so no credential-shaped value is read from browser storage.
2026-09-14 16:45:20 +01:00
hermes 2d31e5a8b9 fix(security): validate libds in stagedata and loadfile
Sanitise the libref.dataset input the same way getdata does, via
mp_validatecol, and abort the service on an invalid value to prevent code
injection through the libds identifier. Format catalog inputs resolve to
work.fmtextract and still pass the check.
2026-09-14 16:45:13 +01:00
hermes cfd8f06435 fix(security): escape cell values in status renderers to prevent DOM XSS
The error/no-spinner/spinner cell renderers wrote the cell value straight
into td.innerHTML. A value containing markup (which can arrive from a dataset
served by the getdata stored program or from a typed edit) was therefore
parsed and executed by the browser. Escape the value so it renders as inert
text, keeping the hardcoded icon markup intact, and add a regression test
that reproduces the injection via a real Handsontable instance.
2026-09-14 16:44:59 +01:00
5 changed files with 115 additions and 13 deletions

No files matched your search

@@ -21,8 +21,6 @@ export class DeployComponent implements OnInit {
public step: number = 0
public adminGroups: any = []
public client_id: string = ''
public client_secret: string = ''
public appLoc: string = ''
public dcPath: string = ''
public selectedAdminGroup: string = ''
@@ -52,9 +50,6 @@ export class DeployComponent implements OnInit {
this.sasJs = this.sasService.getSasjsInstance()
this.sasJsConfig = this.sasService.getSasjsConfig()
this.appLoc = this.dcAdapterSettings?.appLoc || ''
this.client_id = localStorage.getItem('deploy_client_id') || ''
this.client_secret = localStorage.getItem('deploy_secret_key') || ''
this.dcPath = localStorage.getItem('deploy_dc_loc') || ''
}
ngOnInit() {
@@ -1,5 +1,10 @@
import Handsontable from 'handsontable'
import { makeNumberFormatRenderer } from './renderers.utils'
import {
makeNumberFormatRenderer,
errorRenderer,
noSpinnerRenderer,
spinnerRenderer
} from './renderers.utils'
describe('makeNumberFormatRenderer', () => {
it('renders a numeric cell as EUR currency without changing the value', () => {
@@ -86,3 +91,67 @@ describe('makeNumberFormatRenderer', () => {
container.remove()
})
})
/**
* DOM-injection reproduction mirroring the editor's cell-render cycle.
* During dynamic cell validation the editor applies one of the status
* renderers to a cell via setCellMeta + hot.render(). Those renderers paint
* the cell value with td.innerHTML, so a value containing markup is injected
* and executed (the <img onerror> fires in the browser). The value can come
* straight from a dataset row served by the getdata stored program, or from a
* typed edit. These fail on the vulnerable implementation and pass once the
* renderer escapes the value.
*/
describe('grid cell renderers do not inject raw HTML', () => {
const maliciousValue = '<img src=x onerror=alert(1)>'
// Seed a real Handsontable grid with the payload as a loaded cell value,
// then apply the given status renderer and render — exactly the sequence the
// editor uses during the dynamic-validation cycle.
const renderWith = (
renderer: (
i: any,
td: any,
r: number,
c: number,
p: any,
v: any,
cp: any
) => any
) => {
const container = document.createElement('div')
document.body.appendChild(container)
const hot = new Handsontable(container, {
data: [{ SOME_CHAR: maliciousValue }],
columns: [{ data: 'SOME_CHAR', type: 'text' }],
licenseKey: 'non-commercial-and-evaluation'
})
hot.render()
hot.setCellMeta(0, 0, 'renderer', renderer)
hot.render()
const td: HTMLTableCellElement | null = hot.getCell(0, 0)
hot.destroy()
container.remove()
return td
}
// A vulnerable renderer turns the value into a real <img> element with an
// onerror handler (proven by the browser firing alert(1)). A safe
// renderer leaves no such element. Asserting on the parsed DOM rather
// than the raw string avoids false passes from browser attribute normalising.
const assertNoInjectedElement = (td: HTMLTableCellElement | null) => {
expect(td?.querySelector('img[onerror]')).toBeNull()
}
it('noSpinnerRenderer escapes rather than injecting the value', () => {
assertNoInjectedElement(renderWith(noSpinnerRenderer))
})
it('errorRenderer escapes rather than injecting the value', () => {
assertNoInjectedElement(renderWith(errorRenderer))
})
it('spinnerRenderer escapes rather than injecting the value', () => {
assertNoInjectedElement(renderWith(spinnerRenderer))
})
})
+21 -7
View File
@@ -1,5 +1,23 @@
import Handsontable from 'handsontable'
/**
* Returns string-safe text of any value so it can be assigned to innerHTML.
* The cell values painted by the status renderers are user/DB-controlled,
* so they must never be parsed as HTML by the browser — escaping turns any
* embedded markup into inert text.
*/
const escapeHtml = (value: any): string =>
String(value ?? '').replace(/[&<>"']/g, (char) => {
const entities: Record<string, string> = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;'
}
return entities[char]
})
/**
* Builds a display-only HOT renderer that formats numeric cell values using
* Intl.NumberFormat. The stored/submitted value is never changed — only the
@@ -67,9 +85,7 @@ export const errorRenderer = (
) => {
addDarkClass(td)
td.innerHTML = `${
value ? value.toString() : ''
} <cds-icon shape="exclamation-triangle" status="warning"></cds-icon>`
td.innerHTML = `${escapeHtml(value)} <cds-icon shape="exclamation-triangle" status="warning"></cds-icon>`
return td
}
@@ -89,7 +105,7 @@ export const noSpinnerRenderer = (
) => {
addDarkClass(td)
td.innerHTML = value ? value : ''
td.innerHTML = escapeHtml(value)
return td
}
@@ -110,9 +126,7 @@ export const spinnerRenderer = (
) => {
addDarkClass(td)
td.innerHTML = `${
value ? value.toString() : ''
} <span class="spinner spinner-sm vertical-align-middle"></span>`
td.innerHTML = `${escapeHtml(value)} <span class="spinner spinner-sm vertical-align-middle"></span>`
return td
}
+12
View File
@@ -113,9 +113,21 @@ data _null_;
end;
else call symputx('libds',libds);
call symputx('is_fmt',is_fmt);
/* validate libds to prevent code injection */
%mp_validatecol(LIBDS,LIBDS,is_libds)
if is_libds=0 then do;
putlog 'ERR' 'OR: Invalid libds:' libds;
call symputx('bad_libds',1);
end;
else call symputx('bad_libds',0);
putlog (_all_)(=);
run;
%mp_abort(iftrue= (&bad_libds=1)
,mac=&_program
,msg=%str(Invalid libds supplied)
)
/* check that the user has the requisite access */
%mpe_getgroups(user=&user,outds=groups)
+12
View File
@@ -66,9 +66,21 @@ data _null_;
end;
else call symputx('libds',libds);
call symputx('is_fmt',is_fmt);
/* validate libds to prevent code injection */
%mp_validatecol(LIBDS,LIBDS,is_libds)
if is_libds=0 then do;
putlog 'ERR' 'OR: Invalid libds:' libds;
call symputx('bad_libds',1);
end;
else call symputx('bad_libds',0);
putlog (_all_)(=);
run;
%mp_abort(iftrue= (&bad_libds=1)
,mac=&_program
,msg=%str(Invalid libds supplied)
)
%mp_cntlout(
iftrue=(&is_fmt=1)
,libcat=&orig_libds