Skip to content
Snippets Groups Projects
Commit 0152c43a authored by Serge Bazanski's avatar Serge Bazanski Committed by stuebinm
Browse files

SECURITY: Fix path traversal in script verification

The following used to be allowed:

   scripts: https://static.rc3.world/scripts/../maps/81c8add623eea2704f20/e65b545e-342f-4be0-b369-c0eacff7b15d/re-blessed.mp3.js

This is obviously not good, as it allows scripts from arbitrary maps.
parent 89a4aa1e
No related branches found
No related tags found
No related merge requests found
Pipeline #12891 passed
...@@ -12,7 +12,7 @@ module Properties (checkMap, checkTileset, checkLayer) where ...@@ -12,7 +12,7 @@ module Properties (checkMap, checkTileset, checkLayer) where
import Control.Monad (forM, forM_, unless, when) import Control.Monad (forM, forM_, unless, when)
import Data.Text (Text, intercalate, isPrefixOf) import Data.Text (Text, intercalate, isPrefixOf, isInfixOf)
import qualified Data.Text as T import qualified Data.Text as T
import qualified Data.Vector as V import qualified Data.Vector as V
import Tiled (Layer (..), Object (..), Property (..), import Tiled (Layer (..), Object (..), Property (..),
...@@ -142,7 +142,8 @@ checkMapProperty p@(Property name _) = case name of ...@@ -142,7 +142,8 @@ checkMapProperty p@(Property name _) = case name of
-- scripts can be used by one map -- scripts can be used by one map
_ | T.toLower name == "script" -> _ | T.toLower name == "script" ->
unwrapString p $ \str -> unwrapString p $ \str ->
unless ("https://static.rc3.world/scripts" `isPrefixOf` str) unless (("https://static.rc3.world/scripts" `isPrefixOf` str) &&
(not $ "/../" `isInfixOf` str))
$ forbid "only scripts hosted on static.rc3.world are allowed." $ forbid "only scripts hosted on static.rc3.world are allowed."
| name `elem` ["jitsiRoom", "bbbRoom", "playAudio", "openWebsite" | name `elem` ["jitsiRoom", "bbbRoom", "playAudio", "openWebsite"
, "url", "exitUrl", "silent", "getBadge"] , "url", "exitUrl", "silent", "getBadge"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment