File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -74,8 +74,8 @@ flag bytestring-builder
74
74
manual : False
75
75
76
76
flag cffi
77
- description : Controls whether to include c-ffi bits or pure haskell
78
- default : True
77
+ description : Controls whether to include c-ffi bits or pure haskell. Default to False for security.
78
+ default : False
79
79
manual : True
80
80
81
81
library
Original file line number Diff line number Diff line change
1
+ -- WARNING: This file is security sensitive as it uses unsafeWrite which does
2
+ -- not check bounds. Any changes should be made with care and I would love to
3
+ -- get informed about them, just cc me in any PR targetting this file: @eskimor
4
+ -- I would be happy to review the changes!
5
+
6
+ -- The security check at the end (pos > length) only works if pos grows
7
+ -- monotonously, if this condition does not hold, the check is flawed.
1
8
module Data.Aeson.Parser.UnescapePure
2
9
(
3
10
unescapeText
@@ -145,8 +152,8 @@ unescapeText' bs = runText $ \done -> do
145
152
dest <- A. new len
146
153
(pos, finalState) <- B. foldl' (f' dest) (return (0 , StateNone )) bs
147
154
148
- -- Check final state.
149
- when ( finalState /= StateNone )
155
+ -- Check final state. Currently pos gets only increased over time, so this check should catch overflows.
156
+ when ( finalState /= StateNone || pos > len )
150
157
throwDecodeError
151
158
152
159
done dest pos -- TODO: pos, pos-1??? XXX
@@ -248,8 +255,6 @@ unescapeText' bs = runText $ \done -> do
248
255
249
256
{-# INLINE f #-}
250
257
251
- {-# INLINE unescapeText' #-}
252
-
253
258
write :: A. MArray s -> Int -> Word16 -> ST s ()
254
259
write dest pos char =
255
260
A. unsafeWrite dest pos char
You can’t perform that action at this time.
0 commit comments