diff --git a/docs/labs/sending_output.html b/docs/labs/sending_output.html new file mode 100644 index 00000000..ba980f11 --- /dev/null +++ b/docs/labs/sending_output.html @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Format Strings and Templates Lab

+

+This is a lab exercise on developing secure software. +For more information, see the introduction to +the labs. + +

+

Task

+

+Restrict the JNDI hostnames from which variables can be loaded. + +

+

Background

+

+In this exercise, we'll assume that out output template allows a user to specify a JNDI hostname + from which to load variables from. As is the case in the Log4j logging framework. + +

+

Task Information

+

+ +

+Please change the code below so that it restricts the JNDI hostnames from which variables can be + loaded to only the local network interface (127.0.0.1). Use IPv4 addresses only. + + +

+

Interactive Lab (to be completed)

+

+

+

+    public class JndiManager extends AbstractManager {
+        
+
+        /**
+         * Looks up a named object through this JNDI context.
+         *
+         * @param name name of the object to look up.
+         * @param   the type of the object.
+         * @return the named object if it could be located.
+         * @throws  NamingException if a naming exception is encountered
+         */
+        @SuppressWarnings("unchecked")
+        public  T lookup(final String name) throws NamingException {
+            URI uri = new URI(name);
+            if (!allowedHosts.contains(uri.getHost())) {
+                LOGGER.warn("Attempt to access ldap server not in allowed list");
+                return null;
+            }
+            return (T) this.context.lookup(name);
+        }
+    }
+
+ + + +

+

+This lab was developed by Jason Shepherd at +Red Hat Product Security. +

+

+ +

+

+

+

+ Source: This example is a modified version of the patch for CVE-2021-44228 in + apache/logging-log4j2 + +

+
+ + + \ No newline at end of file