hledger/hledger-web
Arsen Arsenović 9ce55146c8 fix: web: b64 encode user controlled input (#1525)
This fixes a reported Stored XSS vulnerability in toBloodhoundJson by
encoding the user-controlled values in this payload into base64 and
parsing them with atob.

In my exploration of the vulnerability with various payloads I and
others crafted, it would appear that this is the only available XSS in
hledger-web in relation to stored accounts and transaction details. If
there is other parts of the UI which may contain user-controlled data,
they should be examined for similar things. In this instance,
protections provided by yesod and other libraries worked fine, but in a
bit of code that hledger-web was generating, the user could insert a
</Script> tag (which is valid HTML and equivalent to </script> but not
caught by the T.Replace that existed in toBloodhoundJson) in order to
switch out of a script context, allowing the parser to be reset, and for
arbitrary JavaScript to run.

The real fix is a bit more involved, but produces much better results:
Content-Security-Policy headers should be introduced, and using
sha256-<hash of script> or a different algorithm, they should be marked
as trusted in the header. This way, if the (in-browser) parser and
hledger-web generator disagree on the source code of the script, the
script won't run. Note that this would still be susceptible to attacks
that involve changing the script by escaping from the string inside it
or something similar to that, which can be avoided additionally by using
either the method used in this commit, or a proper JSON encoder.

The second approach has the advantage of preventing further XSS, to the
extent specified above, in practice, a combination of both should be
used, b64 for embedded data and the CSP sha256-hash script-src over
everything else, which will eliminate all injected or malformed script
blocks (via CSP), in combination with eliminating any HTML closing tags
which might occur in stored data (via b64).

This vulnerability appears to have been first introduced when
autocompletion was added in hledger-web, git tag hledger-0.24, commit
hash: ec51d28839

Test payload: </Script><svg onload=alert(1)//>

Closes #1525
2021-08-24 05:04:12 -10:00
..
app ;web: drop unnecessary import that hiding Prelude in make ghci-web 2020-05-21 09:27:07 -07:00
config web: /version provides hledger version string as JSON (#1152) 2020-09-29 17:28:03 -07:00
deploy web: update for yesod 1.1.3 2012-11-15 17:48:48 +00:00
Hledger fix: web: b64 encode user controlled input (#1525) 2021-08-24 05:04:12 -10:00
static web: fix a bug with keypress listener on the final amount input in AddForm not getting initialized correctly 2021-05-03 07:17:09 -10:00
templates lib!: lib,web: Remove unused TransactionReport. Move the useful utility 2021-07-22 19:00:37 -10:00
test web: --test [-- HSPECARGS] runs the test suite 2020-11-16 14:02:16 -08:00
.date.m4 ;doc: bump man page dates 2021-08-08 09:39:20 -10:00
.eslintrc.js fix datepicker not closing, linting 2017-12-30 13:44:40 -05:00
.ghci web: drop cruft from .ghci 2016-04-18 15:28:54 -07:00
.version ;pkg: bump version to 1.22.99 2021-08-03 00:24:20 -10:00
.version.m4 ;pkg: bump version to 1.22.99 2021-08-03 00:24:20 -10:00
CHANGES.md ;doc: update changelogs 2021-08-19 18:36:34 -10:00
dir-entry.texi ;fix: doc: info: avoid directory paths in directory metadata (#1594) 2021-07-14 09:07:56 -10:00
hledger-web.1 ;doc: update manuals 2021-08-08 09:39:20 -10:00
hledger-web.cabal fix: web: b64 encode user controlled input (#1525) 2021-08-24 05:04:12 -10:00
hledger-web.info ;doc: update manuals 2021-08-08 09:39:20 -10:00
hledger-web.m4.md ;doc: ui, web: move screenshot styles elsewhere 2021-07-28 22:24:25 -10:00
hledger-web.txt ;doc: update manuals 2021-08-08 09:39:20 -10:00
LICENSE packagegeddon.. split off web/chart/vty, move hledger to a subdir 2010-09-09 22:54:34 +00:00
package.yaml fix: web: b64 encode user controlled input (#1525) 2021-08-24 05:04:12 -10:00
README.md ;doc: more tweaks to package readmes, hackage descriptions 2020-03-22 10:49:02 -07:00
Setup.hs Revert "remove Setup.hs files again, fixing a yesod devel warning" 2014-05-24 13:39:09 -07:00

hledger-web

A simple web-based user interface for the hledger accounting system, providing a more modern UI than the command-line or terminal interfaces. It can be used as a local single-user UI, or as a multi-user UI for viewing/adding/editing on the web.

See also: the project README and home page.