{"record":{"id":"f1163e57ab557690","repo":"NationalSecurityAgency/ghidra","slug":"improperly-formatted-distinguished-name","errorCode":null,"errorMessage":"Improperly formatted distinguished name","messagePattern":"Improperly formatted distinguished name","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java","lineNumber":429,"sourceCode":"\tprivate void validateDistinguishedName() throws IllegalArgumentException {\n\t\tif (distinguishedName == null) {\n\t\t\treturn;\n\t\t}\n\t\tcommonName = null;\n\t\ttry {\n\t\t\tLdapName ldapName = new LdapName(distinguishedName);\n\t\t\tfor (Rdn rdn : ldapName.getRdns()) {\n\t\t\t\tif (rdn.getType().equalsIgnoreCase(\"CN\")) {\n\t\t\t\t\tcommonName = rdn.getValue().toString();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (commonName == null) {\n\t\t\t\tthrow new IllegalArgumentException(\"Missing common name attribute\");\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tthrow new IllegalArgumentException(\"Improperly formatted distinguished name\");\n\t\t}\n\t}\n\n\t/**\n\t * @return true if the server (referred to by -postgresRoot-) is running\n\t * @throws IOException if there is a problem running the command\n\t * @throws InterruptedException if there is a problem running the command\n\t */\n\tprivate boolean isServerRunning() throws IOException, InterruptedException {\n\t\tFile createCommand = new File(postgresRoot, \"bin/pg_isready\");\n\t\tList<String> command = new ArrayList<String>();\n\t\tcommand.add(createCommand.getAbsolutePath());\n\t\tif ((port != -1) && (port != 5432)) {\t// Non-default port\n\t\t\tcommand.add(\"-p\");\n\t\t\tcommand.add(Integer.toString(port));\n\t\t}\n\t\tint ret = runCommand(null, command, loadLibraryVar, loadLibraryValue);\n\t\treturn (ret == 0);","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java#L411-L447","documentation":"Thrown by validateDistinguishedName's catch-all when constructing LdapName or iterating its RDNs raises any Exception (e.g. malformed DN syntax, bad escaping, invalid characters). It is a broad safety net wrapping any parsing failure.","triggerScenarios":"Passing a DN that violates RFC 2253 syntax, e.g. unescaped special characters, wrong separators, or garbage like `--dn \"CN=server;O=Acme\"` (semicolon instead of comma).","commonSituations":"Bad escaping of commas/plus/equals inside values, stray punctuation, or using semicolons/spaces as separators.","solutions":["Use valid RFC 2253 syntax: comma-separated key=value pairs.","Escape special characters (comma, plus, equals, quotes) per RFC 2253.","Test the DN with an LDAP/LdapName parser before passing it."],"exampleFix":"// before\nbsim control configure host --auth pki --dn \"CN=server;O=Acme\"\n// after\nbsim control configure host --auth pki --dn \"CN=server,O=Acme\"","handlingStrategy":"try-catch","validationCode":"// Pre-parse the DN with javax.naming.ldap.LdapName to catch syntax errors early.\ntry {\n    new javax.naming.ldap.LdapName(dn);\n} catch (javax.naming.InvalidNameException e) {\n    System.err.println(\"Malformed DN: \" + dn + \" (\" + e.getMessage() + \")\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    launchable.validateDistinguishedName();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"Improperly formatted distinguished name\")) {\n        System.err.println(\"DN must be RFC 2253 syntax (comma-separated key=value).\");\n    }\n    throw e;\n}","preventionTips":["Pre-parse DNs with LdapName to surface syntax errors before launch.","Escape special characters (, + = \" \\) per RFC 2253.","Use commas, not semicolons or spaces, as RDN separators."],"tags":["cli","pki","certificate","validation","security"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}