Commit Graph

355 Commits

Author SHA1 Message Date
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
Simon Michael
6afc5ce6b2 ;cabal: update cabal files 2021-08-03 21:05:29 -10:00
Simon Michael
95de5a878a ;cabal: update cabal files 2021-08-03 08:00:22 -10:00
Simon Michael
9aac520edd deps: allow megaparsec 9.1 2021-07-20 20:38:39 -10:00
Simon Michael
26bc5e6df3 ;update cabal files 2021-06-28 22:38:12 -10:00
Simon Michael
b681cde62d ;update cabal files 2021-06-03 14:08:47 -10:00
Simon Michael
d3b20675d0 tools: really regenerate the cabal files with stack's hpack
hpack has dropped the hash at last, this should help a lot to reduce
edit conflicts and commit noise.
2021-05-14 16:14:06 -10:00
Felix Yan
684af10643 Allow yesod-form 1.7
Builds fine and all tests pass here.
2021-04-23 10:15:27 -10:00
Simon Michael
eb2da22f63 ;update cabal files 2021-04-04 08:03:57 -10:00
Simon Michael
d0940bf8ce ;update cabal files 2021-03-29 08:19:54 -07:00
Simon Michael
ae57e76cb3 ;update cabal files 2021-03-12 06:59:30 -08:00
Simon Michael
5573538fdc ;update cabal files 2021-03-10 13:50:50 -08:00
Simon Michael
00beaf1423 ;update cabal files 2021-03-10 08:24:59 -08:00
Simon Michael
f7bbb39a77 ;regenerate cabal files with the hpack version in current stack
To minimise warnings. They got regenerated by a commit for #1471.
2021-02-18 13:42:40 -08:00
Arnout Engelen
ad2ab3c823 Make sure to round up for the 'to' date 2021-02-17 09:05:13 -08:00
Simon Michael
9afccde16f ;update cabal files 2020-12-14 12:31:01 -08:00
Simon Michael
1856ca5312 web: bump to 1.20.1; update manuals' dates 2020-12-06 18:20:56 -08:00
Simon Michael
5507cb07ef ;update cabal files 2020-11-30 15:19:21 -08:00
Simon Michael
ee73a6aabf web: --test [-- HSPECARGS] runs the test suite 2020-11-16 14:02:16 -08:00
Simon Michael
3651a5f5f4 ;web: tests: refactor, add a test for --forecast (#1390) 2020-11-13 16:40:33 -08:00
Simon Michael
c7e267e314 ;web: begin work on a forecasting test (#1390) 2020-11-13 09:42:06 -08:00
Simon Michael
290428f9d4 web: re-enable the test suite; add a test for /journal (#1390) 2020-11-13 09:37:56 -08:00
TANIGUCHI Kohei
906da6e6bd Fix hledger-web description
Slashes need to be escaped or they introduce unexpected italic style
due to Haddock markup.
2020-10-22 00:33:47 -07:00
Simon Michael
1affcb727c ;update cabal files 2020-09-11 16:59:53 -07:00
Simon Michael
bc2670204f ;update missed hledger-web cabal file 2020-09-07 15:40:43 -07:00
Felix Yan
c6f33cc824 Remove redundant semigroups dependency 2020-09-07 12:12:46 -07:00
Simon Michael
3170cc7cbd bump version to 1.19 2020-09-01 20:27:17 -07:00
Simon Michael
e090e0f949 add lower bound needed for aeson, to help cabal (#1268) 2020-06-23 14:55:42 -07:00
Simon Michael
24996caaeb bump to dev version 2020-06-21 10:35:52 -07:00
Simon Michael
729e87066f ;cabal files 2020-06-07 13:00:40 -07:00
Simon Michael
a54376e204 ;regen cabal files 2020-06-06 17:20:13 -07:00
Henning Thielemann
c35d0a8b44 ;web: transaction fragments: use numeric identifiers for journal files
This saves us from any escaping issues.
2020-05-25 10:02:39 -07:00
Simon Michael
6935c46b2c ;regen cabal files with latest stack/hpack (2.3.1/0.33.0) 2020-05-02 17:31:35 -07:00
Simon Michael
d868a7e170 ;update cabal files 2020-03-22 10:49:49 -07:00
Simon Michael
40d3a5c1f4 ;update cabal files 2020-03-22 09:28:10 -07:00
Simon Michael
2b15418ddd ;update cabal files 2020-03-22 09:08:37 -07:00
Simon Michael
96b4f0be4f require newer Decimal, math-functions, fixing inconsistent rounding
Decimal 0.5.1+ changed to banker's rounding (round to nearest even
number), and math-functions 0.3.3.0 (used by roi) fixed various
precision-related issues. Now we require the latest versions of these.
This was causing some functional test failures when building with old
GHCs/snapshots.
2020-03-19 10:10:55 -07:00
Simon Michael
1883ff4499 bump to dev version 2020-03-07 15:06:18 -08:00
Simon Michael
6dfdc2bee8 ;one more cabal file update. Not in hackage tarballs. 2020-03-01 17:42:20 -08:00
Simon Michael
ba44d00bed ;bump version to 1.17 2020-03-01 17:29:01 -08:00
Simon Michael
7011160bfd ;allow base 4.14/GHC 8.10 2020-01-26 08:12:25 -08:00
Amarandus
76ffaca466 web: Add IPv6 and hostname support
This commit introduces IPv6 support (and thus closes #1145).
It also allows using local hostnames as a parameter for --host.
For this, multiple things needed to be changed:

 - checkWebOpts is dropped, as the supplied parameter is checked later
 by Network.Socket.getAddrInfo
 - defbaseurl needs to check if : is used in the host, as this indicates
 the usage of an IPv6 address. In this case, the host needs to be
 wrapped in [] for the base URL
 - To allow opening such a modified base URL, runHostPortFullUrl is used
 instead of runhostPortUrl, as it allows opening arbitrary URLs instead
 of a path prefixed with http://127.0.0.1

As checking the host for validity is postponed until the webserver tries
to start, an invalid hostname leads to an exception caused by
Network.Socket.getAddrInfo.
This is still fine, as hledger-web won't start in an undefined state, but
will terminate with a nonzero exit code.
2020-01-17 13:18:51 -08:00
Simon Michael
445e8aa3cc add support for megaparsec 8 (#1175) 2020-01-14 09:54:06 -08:00
Carl Richard Theodor Schneider
72acd7c22a web: Add option --socket to use UNIX socket file
This commit adds the --socket option to use hledger-web over an AF_UNIX socket
file.
It allows running multiple instances of hledger-web on the same system without
having to manually choose a port for each instance, which is helpful for running
individual instances for multiple users. In this scenario, the socket path is
predictable, as it can be derived from the username.

It also introduces the following dependencies:

 - network
   - Used to create the unix domain socket
 - unix-compat
   - Used to identify if the socket file is still a socket, to reduce the risk
     of deleting a file when cleaning up the socket
2020-01-12 16:15:37 -08:00
Simon Michael
cfb2a61ae1 ;bump to dev version; bump man page dates
[ci skip]
2020-01-05 09:04:50 -08:00
Stephen Morgan
74778efcf5 Use nubSort instead of nub . sort. 2020-01-04 08:31:10 -08:00
Simon Michael
46d516e7a3 move JSON instances from hledger-web to hledger-lib 2019-12-16 17:17:00 -08:00
Simon Michael
093dca570d lib, cli, web: bump version to 1.16.1 2019-12-03 08:41:44 -08:00
Simon Michael
b7bea5698e web: drop old dependency on json (#1190) 2019-12-03 08:41:44 -08:00
Simon Michael
0ce890e5ff lib, cli, web: drop unnecessary mtl-compat dependency 2019-12-02 08:23:00 -08:00