Skip to content

Commit

Permalink
Fix an XSS issue
Browse files Browse the repository at this point in the history
- improve value escaping
- fix handling of unsupported path suffixes
  • Loading branch information
tomachalek committed Dec 12, 2022
1 parent c54df51 commit 9534a9e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/controller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,11 @@ def wrapper(func):


def val_to_js(obj):
return re.sub(r'<(/)?(script|iframe|frame|frameset|embed|img|object)>', r'<" + "\g<1>\g<2>>', json.dumps(obj),
flags=re.IGNORECASE)
return markupsafe.Markup(
json.dumps(obj).replace("<", "\\u003c")
.replace(">", "\\u003e")
.replace("&", "\\u0026")
.replace("'", "\\u0027"))


class KonTextCookie(http.cookies.BaseCookie):
Expand Down Expand Up @@ -687,7 +690,10 @@ def run(self, path: Optional[List[str]] = None) -> Tuple[str, List[Tuple[str, st
self._install_plugin_actions()
self._proc_time = time.time()
path = path if path is not None else self._import_req_path()
methodname = path[0]
path_elms = [x for x in path if x]
if len(path_elms) > 1:
raise NotFoundException('Unknown path')
methodname = path_elms[0]
headers: List[Tuple[str, str]] = []
err: Optional[Tuple[Exception, Optional[str]]] = None
action_metadata: Dict[str, Any] = self._get_method_metadata(methodname)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ babel >= 2.8.0
mysql-connector-python >= 8.0.25
dataclasses-json >= 0.5.4
couchdb >= 1.2
markupsafe >= 2.1.1

rq-scheduler >= 0.10.0
rq >= 1.5.1

0 comments on commit 9534a9e

Please sign in to comment.