-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SECURITY][XBOW-024-109] Fix XSS vulnerability in header link rendering
- Tightened footnote parsing in `JSPWikiMarkupParser`: * When `m_allowHTML` is false, added HTML entity escaping for footnote link text. - Added support in `MarkdownDocument` to honor `jspwiki.translatorReader.allowHTML` property: * Set `HtmlRenderer.ESCAPE_HTML` option based on the property value. These changes mitigate the XSS vulnerability identified in XBOW-024-109, ensuring safer input handling for both JSPWiki Core and Markdown modules.
- Loading branch information
1 parent
a184e0a
commit 402f9a1
Showing
5 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1947,4 +1947,32 @@ public void testAmpersand2() throws Exception { | |
"----\n" + | ||
"author: [Asser], [Ebu], [JanneJalkanen], [Jarmo|mailto:[email protected]]\n"; | ||
|
||
|
||
@Test | ||
public void testEscapeHTMLWhenHTMLNotAllowed() throws Exception { | ||
final String src = "This should be a [#1 <script>alert('XSS')</script>]"; | ||
testEngine = TestEngine.build(with("jspwiki.translatorReader.allowHTML", "false")); // Disable HTML | ||
final Page page = Wiki.contents().page(testEngine, PAGE_NAME); | ||
final String output = translate(testEngine, page, src); | ||
Assertions.assertEquals( | ||
"This should be a <a class=\"footnote\" name=\"ref-testpage-1 <script>alert('XSS')</script>\">[#1 <script>alert('XSS')</script>]</a>", | ||
output | ||
); | ||
} | ||
|
||
|
||
@Test | ||
public void testNoEscapeHTMLWhenHTMLAllowed() throws Exception { | ||
final String src = "This should be a [#1 <b>bold</b>]"; | ||
testEngine = TestEngine.build(with("jspwiki.translatorReader.allowHTML", "true")); // Enable HTML | ||
final Page page = Wiki.contents().page(testEngine, PAGE_NAME); | ||
final String output = translate(testEngine, page, src); | ||
Assertions.assertEquals( | ||
"This should be a <a class=\"footnote\" name=\"ref-testpage-1 <b>bold</b>\">[#1 <b>bold</b>]</a>", | ||
output | ||
); | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters