<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Philippe Arteau on Medium]]></title>
        <description><![CDATA[Stories by Philippe Arteau on Medium]]></description>
        <link>https://medium.com/@h3xstream?source=rss-78123d4d0839------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*SsEEC8k3HPFCeiIu.png</url>
            <title>Stories by Philippe Arteau on Medium</title>
            <link>https://medium.com/@h3xstream?source=rss-78123d4d0839------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 12:38:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@h3xstream/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Security Puzzle (Log4J Edition)]]></title>
            <link>https://medium.com/@h3xstream/security-puzzle-log4j-edition-1fb5b6d708ef?source=rss-78123d4d0839------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fb5b6d708ef</guid>
            <category><![CDATA[code-review]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[challenge]]></category>
            <category><![CDATA[log4j-vulnerability]]></category>
            <dc:creator><![CDATA[Philippe Arteau]]></dc:creator>
            <pubDate>Mon, 10 Jan 2022 16:16:00 GMT</pubDate>
            <atom:updated>2022-01-11T00:36:26.192Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*svPr0nV-7roHTTSX.png" /></figure><p>Apache Log4J has been in the spotlight for its JNDI feature introducing a major security flaw in december.</p><p>Here is the function for JNDI lookups modified to avoid unexpected remote class being loaded. This function was used to fix potential RCE in version 2.15.</p><p>Can you see why the validation was <strong>insufficient</strong>?</p><pre>private final DirContext context; //javax.naming.directory.DirContext<br><br>[...]<br><br>@SuppressWarnings(&quot;unchecked&quot;)<br>public &lt;T&gt; T lookup(final String name) throws NamingException {<br>public synchronized &lt;T&gt; T lookup(final String name) throws NamingException {<br><br>try {<br>    URI uri = new URI(name);<br>    if (uri.getScheme() != null) {<br>        if (!allowedProtocols.contains(uri.getScheme().toLowerCase(Locale.ROOT))) {<br>            LOGGER.warn(&quot;Log4j JNDI does not allow protocol {}&quot;, uri.getScheme());<br>            return null;<br>        }<br>        if (LDAP.equalsIgnoreCase(uri.getScheme()) || LDAPS.equalsIgnoreCase(uri.getScheme())) {<br>            if (!allowedHosts.contains(uri.getHost())) {<br>                LOGGER.warn(&quot;Attempt to access ldap server not in allowed list&quot;);<br>                return null;<br>            }<br>            Attributes attributes = this.context.getAttributes(name);<br>            if (attributes != null) {<br>                // In testing the &quot;key&quot; for attributes seems to be lowercase while the attribute id is<br>                // camelcase, but that may just be true for the test LDAP used here. This copies the Attributes<br>                // to a Map ignoring the &quot;key&quot; and using the Attribute&#39;s id as the key in the Map so it matches<br>                // the Java schema.<br>                Map&lt;String, Attribute&gt; attributeMap = new HashMap&lt;&gt;();<br>                NamingEnumeration&lt;? extends Attribute&gt; enumeration = attributes.getAll();<br>                while (enumeration.hasMore()) {<br>                    Attribute attribute = enumeration.next();<br>                    attributeMap.put(attribute.getID(), attribute);<br>                }<br>                Attribute classNameAttr = attributeMap.get(CLASS_NAME);<br>                if (attributeMap.get(SERIALIZED_DATA) != null) {<br>                    if (classNameAttr != null) {<br>                        String className = classNameAttr.get().toString();<br>                        if (!allowedClasses.contains(className)) {<br>                            LOGGER.warn(&quot;Deserialization of {} is not allowed&quot;, className);<br>                            return null;<br>                        }<br>                    } else {<br>                        LOGGER.warn(&quot;No class name provided for {}&quot;, name);<br>                        return null;<br>                    }<br>                } else if (attributeMap.get(REFERENCE_ADDRESS) != null<br>                        || attributeMap.get(OBJECT_FACTORY) != null) {<br>                    LOGGER.warn(&quot;Referenceable class is not allowed for {}&quot;, name);<br>                    return null;<br>                }<br>            }<br>        }<br>    }<br>} catch (URISyntaxException ex) {<br>    // This is OK.<br>}<br>return (T) this.context.lookup(name);<br><br>}</pre><p>Ref: <a href="https://github.com/apache/logging-log4j2/commit/d82b47c6fae9c15fcb183170394d5f1a01ac02d3#diff-271353c1076e53f6893261e4420de27d34588bfd782806b5c66a3465c43b7f51R209">Changeset</a></p><h3>What is/are the weakness in the code above?</h3><ul><li>A) Incomplete blacklist / whitelist</li><li>B) Improper URL parsing</li><li>C) Unexpected Nullpointer</li><li>D) Exception handling</li><li>E) Time of Check, Time of Use</li></ul><p><em>For the answer visit the dev.to post. (Medium does not support spoiler block.)</em></p><p><em>Originally published at </em><a href="https://dev.to/h3xstream/security-puzzle-log4j-edition-465f"><em>https://dev.to</em></a><em> on January 10, 2022.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fb5b6d708ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bypassing ModSecurity WAF]]></title>
            <link>https://medium.com/@h3xstream/bypassing-modsecurity-waf-3ba08ba9a7c?source=rss-78123d4d0839------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ba08ba9a7c</guid>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[libinjection]]></category>
            <category><![CDATA[firewall]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Philippe Arteau]]></dc:creator>
            <pubDate>Thu, 21 Oct 2021 02:10:12 GMT</pubDate>
            <atom:updated>2022-01-31T08:05:34.047Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*reKwA-ijJuuBBZqes5WTHg.png" /></figure><p>Being able to bypass Web Application Firewall (WAF) depends on your knowledge about their behavior. Here is a cool technique that involve <strong>expressions that are ignored in MySQL SQL parser</strong> ( <a href="https://bugs.mysql.com/bug.php?id=105143">MySQL &lt;= 5.7</a>). This post summarizes the impact on libinjection. The <a href="https://github.com/client9/libinjection">libinjection library</a> is used by WAF such as <a href="https://github.com/SpiderLabs/ModSecurity">ModSecurity</a> and <a href="https://docs.fastly.com/signalsciences/how-it-works/">SignalScience</a>. For more details on AWS Cloudfront impact, read the <a href="https://www.gosecure.net/blog/2021/10/19/a-scientific-notation-bug-in-mysql-left-aws-waf-clients-vulnerable-to-sql-injection/">original GoSecure article</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*QOQSYyjd8HL9avC8_ENMcg.jpeg" /></figure><h3>Scientific expression in MySQL</h3><p>When MySQL sees 1.e(abc), it will ignore the 1.e( portion because the following characters do not form a valid numeric value.</p><p>This behavior can be abused to fool libinjection tokenizer. Libinjection internally tokenizes the parameter and identifies contextual section types such as comments and strings. Libinjection sees the string “1.e” as an unknown SQL keyword and concludes that it is more likely to be an English sentence than code. When libinjection is <a href="https://github.com/libinjection/libinjection/blob/49904c42a6e68dc8f16c022c693e897e4010a06c/src/libinjection_sqli_data.h#L8686">unaware of an SQL function</a> the same behavior can be exhibited.</p><h3>Attack in action</h3><p>Here is a demonstration of modsecurity’s capability to block a malicious pattern for SQL injection. A forbidden page is returned which is the consequence of detection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*ZReuRVfjIC6KmA7FYRFaUg.gif" /><figcaption><em>Blocked!</em></figcaption></figure><p>In the following image, you can see the original request being slightly modified to bypass modsecurity and libinjection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*JVMIxkOUpp2v5t7_Pf3sGQ.gif" /><figcaption><em>WAF Bypass!</em></figcaption></figure><h3>Complete payload</h3><p>Now, how do we go beyond or 1=1 payloads? The NUMBER.e expression can be inserted at plenty of locations without breaking the SQL query. The following payload demonstrated read on arbitrary SQL tables.</p><pre>&#39; 1.e(ascii 1.e(substring(1.e(select password from users limit 1 1.e,1 1.e) 1.e,1 1.e,1 1.e)1.e)1.e) = 70 or&#39;1&#39;=&#39;2</pre><p>The same payload was indented below for readability. 1.e( and 1.e, are ignored from the parser.</p><pre>1.e(ascii 1.e(substring( 1.e(select password from users limit 1 1.e,1 1.e) 1.e,1 1.e,1 1.e)1.e)1.e) = 70 #(first char = 70) or&#39;1&#39;=&#39;2</pre><h3>Conclusion</h3><p>Most bypass techniques evolve using special encoding to obfuscate the malicious requests (URL encoding, Unicode multibytes, XML entities, etc). This technique will work if the system behind the WAF is doing an unexpected decoding. This new technique is not encoding related. For this reason, it will be a versatile trick until most system upgrade their MySQL instances.</p><p><em>Full story on </em><a href="https://www.gosecure.net/blog/2021/10/19/a-scientific-notation-bug-in-mysql-left-aws-waf-clients-vulnerable-to-sql-injection/"><em>GoSecure blog</em></a><em> (More details on AWS Cloudfront)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ba08ba9a7c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to solve: “Symbol is declared in module X which does not export package Y”]]></title>
            <link>https://medium.com/@h3xstream/how-to-solve-symbol-is-declared-in-module-x-which-does-not-export-package-y-50602fc3859d?source=rss-78123d4d0839------2</link>
            <guid isPermaLink="false">https://medium.com/p/50602fc3859d</guid>
            <category><![CDATA[build]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[modules]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Philippe Arteau]]></dc:creator>
            <pubDate>Thu, 18 Feb 2021 20:21:43 GMT</pubDate>
            <atom:updated>2022-01-31T07:59:36.963Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*IHTGmDMXgtLVh7-Tlp3yeQ.png" /></figure><p>If you are here, I assume that you have encounter a message like one of these.</p><pre>Symbol is declared in module &#39;java.desktop&#39; which does not export package &#39;sun.awt.image&#39; Symbol is declared in module &#39;java.xml&#39; which does not export package &#39;com.sun.org.apache.xerces.internal.xni.parser&#39; Symbol is declared in module &#39;java.base&#39; which does not export package &#39;sun.net.www.protocol.http&#39;</pre><h3>What is happening?</h3><p>You are accessing a class in a package that was not intended to be used by external library. The class is part of an <strong>internal package that is subject to change</strong>. When updating the library, it is likely that it will break your application.</p><p>These modules restrictions were introduce in Java 9.</p><h3>Option 1: Long-term fix</h3><p>If you are working on a project that has long term stability in mind, you should look for an equivalent function that is public. This may required an additional library.</p><p>Here is a simple example in Kotlin where Strings.isNullOrEmpty was use by accident. The function call can simply be replace by CharSequence.isNullOrEmpty().</p><p><em>Example taken from </em><a href="https://stackoverflow.com/questions/57196948/kotlin-symbol-is-declared-in-module-jdk-internal-opt-which-does-not-export-pa"><em>stackoverflow.com</em></a></p><p>You may still want to use internal API regardless of the recommendation from the compiler. Here are the solution for Java and Kotlin.</p><h3>“I know what am doing” Option 2: Java fix</h3><p>In order to still use the internal API, you will need to pass additional arguments to the compiler (--add-exports ...). This can be configured in your Maven or Gradle build.</p><p>Here is an example of Maven configuration:</p><pre>&lt;build&gt;<br>    &lt;plugins&gt;<br>        &lt;plugin&gt;<br>            &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;<br>            &lt;configuration&gt;<br>                &lt;source&gt;1.9&lt;/source&gt;<br>                &lt;target&gt;1.9&lt;/target&gt;<br>                &lt;compilerArgs&gt;<br>                    &lt;!-- Few examples ... only pick the ones needed --&gt;<br>                    &lt;arg&gt;--add-exports&lt;/arg&gt;&lt;arg&gt;java.xml/com.sun.org.apache.xerces.internal.impl.dtd=ALL-UNNAMED&lt;/arg&gt;<br>                    &lt;arg&gt;--add-exports&lt;/arg&gt;&lt;arg&gt;java.xml/com.sun.org.apache.xerces.internal.xni.parser=ALL-UNNAMED&lt;/arg&gt;<br>                    &lt;arg&gt;--add-exports&lt;/arg&gt;&lt;arg&gt;java.base/sun.net.www.protocol.http=ALL-UNNAMED&lt;/arg&gt;<br>                    &lt;arg&gt;--add-exports&lt;/arg&gt;&lt;arg&gt;jdk.unsupported/sun.misc=ALL-UNNAMED&lt;/arg&gt;<br>                    &lt;arg&gt;--add-exports&lt;/arg&gt;&lt;arg&gt;java.base/sun.security.ssl=ALL-UNNAMED&lt;/arg&gt;<br>                    &lt;arg&gt;--add-exports&lt;/arg&gt;&lt;arg&gt;java.base/sun.security.util=ALL-UNNAMED&lt;/arg&gt;<br>                    &lt;arg&gt;--add-exports&lt;/arg&gt;&lt;arg&gt;java.base/com.sun.net.ssl.internal.ssl=ALL-UNNAMED&lt;/arg&gt;<br>                    &lt;arg&gt;--add-exports&lt;/arg&gt;&lt;arg&gt;java.base/sun.security.jca=ALL-UNNAMED&lt;/arg&gt;<br>                    &lt;arg&gt;--add-exports&lt;/arg&gt;&lt;arg&gt;java.base/sun.net.util=ALL-UNNAMED&lt;/arg&gt;<br>                    &lt;arg&gt;--add-exports&lt;/arg&gt;&lt;arg&gt;java.base/jdk.internal.misc=ALL-UNNAMED&lt;/arg&gt;<br>                    &lt;arg&gt;--add-exports&lt;/arg&gt;&lt;arg&gt;java.base/sun.security.internal.interfaces=ALL-UNNAMED&lt;/arg&gt;<br>                    &lt;arg&gt;--add-exports&lt;/arg&gt;&lt;arg&gt;java.base/sun.security.provider.certpath=ALL-UNNAMED&lt;/arg&gt;<br>                    &lt;arg&gt;--add-exports&lt;/arg&gt;&lt;arg&gt;java.base/sun.security.internal.spec=ALL-UNNAMED&lt;/arg&gt;<br>                    &lt;arg&gt;--add-exports&lt;/arg&gt;&lt;arg&gt;java.base/sun.security.validator=ALL-UNNAMED&lt;/arg&gt;<br>                    &lt;arg&gt;--add-exports&lt;/arg&gt;&lt;arg&gt;java.base/sun.security.action=ALL-UNNAMED&lt;/arg&gt;<br>                    &lt;arg&gt;--add-exports&lt;/arg&gt;&lt;arg&gt;java.base/sun.security.x509=ALL-UNNAMED&lt;/arg&gt;<br>                &lt;/compilerArgs&gt;<br>            &lt;/configuration&gt;<br>        &lt;/plugin&gt;</pre><h3>“I know what am doing” Option 3: Kotlin fix</h3><p>Kotlin does not have a compiler option to turn off specific module restrictions. You can however add an annotation at the beginning of your file to disable module restriction completely.</p><pre>@ file : Suppress ( &quot;JAVA_MODULE_DOES_NOT_EXPORT_PACKAGE&quot; ) import com.sun.org.apache.xerces.internal.util.SAXInputSource import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException [...]</pre><h3>Conclusion</h3><p>While those new module restrictions may seems drastic, they are great safe guard that will help long term maintainability. Before adding exception, take the time to investigate if you really need the internal API.</p><p><em>Originally published at </em><a href="https://dev.to/h3xstream/how-to-solve-symbol-is-declared-in-module-x-which-does-not-export-package-y-303g"><em>https://dev.to</em></a><em> on February 18, 2021.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50602fc3859d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>