Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harden xss security fix #527

Merged
merged 4 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/lcp-wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private function assign_style($info, $tag = null, $css_class = null){
# e.g. If a post has this excerpt: alert(/XSS/) another post could use:
# [catlist excerpt_tag='script' excerpt=yes]
# and the XSS would be triggered.
if ( $tag == 'script' ) {
if ( !empty( $tag ) && strtolower( tag_escape( $tag ) ) == 'script' ) {
$tag = null;
}
if (!empty($info)):
Expand Down
2 changes: 1 addition & 1 deletion list-category-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: List category posts
Plugin URI: https://github.com/picandocodigo/List-Category-Posts
Description: List Category Posts allows you to list posts by category in a post/page using the [catlist] shortcode. This shortcode accepts a category name or id, the order in which you want the posts to display, the number of posts to display and many more parameters. You can use [catlist] as many times as needed with different arguments. Usage: [catlist argument1=value1 argument2=value2].
Version: 0.90.2
Version: 0.90.3
Author: Fernando Briano
Author URI: http://fernandobriano.com

Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: list, categories, posts, cms
Requires at least: 3.3
Tested up to: 6.7.1
Requires PHP: 5.6
Stable tag: 0.90.2
Stable tag: 0.90.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -237,6 +237,10 @@ Template system has changed. Custom templates should be stored in WordPress them

== Changelog ==

= 0.90.3 =

* Hardens xss fix for script tag by checking case insensitive and using tag_escape.

= 0.90.2 =

* Updates fix for stored cross-site scripting from 0.90.0, now applied to all tags. From this version onwards, script is not available to use as a tag when setting an element's tag in the shortcode.
Expand Down
24 changes: 24 additions & 0 deletions tests/lcpwrapper/test-wrap.php
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's great

Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,28 @@ public function test_multiple_classes() {
'<span class="test1 test2 test3">test string</span>',
$wrapper->wrap($this->test_string, null, 'test1 test2 test3'));
}

public function test_script_tag() {
$wrapper = LcpWrapper::get_instance();
$this->assertSame(
'<span class="test">test string</span>',
$wrapper->wrap($this->test_string, 'script', 'test')
);
$this->assertSame(
'test string',
$wrapper->wrap($this->test_string, 'script', null)
);
$this->assertSame(
'test string',
$wrapper->wrap($this->test_string, 'SCRIPT', null)
);
$this->assertSame(
'test string',
$wrapper->wrap($this->test_string, 'sCrIpt', null)
);
$this->assertSame(
'test string',
$wrapper->wrap($this->test_string, 's(cript', null)
);
}
}
Loading