{"record":{"id":"e18f5b929ec0b747","repo":"apache/hadoop","slug":"user-is-null","errorCode":null,"errorMessage":"user is null.","messagePattern":"user is null\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/authorize/DefaultImpersonationProvider.java","lineNumber":113,"sourceCode":"    // get hosts per proxyuser\n    allMatchKeys = conf.getValByRegex(hostsRegEx);\n    for(Entry<String, String> entry : allMatchKeys.entrySet()) {\n      proxyHosts.put(entry.getKey(),\n          new MachineList(entry.getValue()));\n    }\n  }\n\n  @Override\n  public Configuration getConf() {\n    return conf;\n  }\n\n  @Override\n  public void authorize(UserGroupInformation user,\n      InetAddress remoteAddress) throws AuthorizationException {\n    \n    if (user == null) {\n      throw new IllegalArgumentException(\"user is null.\");\n    }\n\n    UserGroupInformation realUser = user.getRealUser();\n    if (realUser == null) {\n      return;\n    }\n    \n    AccessControlList acl = proxyUserAcl.get(configPrefix +\n        realUser.getShortUserName());\n    if (acl == null || !acl.isUserAllowed(user)) {\n      throw new AuthorizationException(\"User: \" + realUser.getUserName()\n          + \" is not allowed to impersonate \" + user.getUserName());\n    }\n\n    MachineList MachineList = proxyHosts.get(\n        getProxySuperuserIpConfKey(realUser.getShortUserName()));\n\n    if(MachineList == null || !MachineList.includes(remoteAddress)) {","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/authorize/DefaultImpersonationProvider.java#L95-L131","documentation":"DefaultImpersonationProvider.authorize throws IllegalArgumentException when the user argument is null. The provider must inspect the effective UserGroupInformation (and its real user) to evaluate proxy ACLs, so a null user is a caller bug, not a authorization failure.","triggerScenarios":"Calling ProxyUsers.authorize(null, remoteAddress) or DefaultImpersonationProvider.authorize(null, addr); passing a UGI variable that was never assigned because authentication was skipped or failed earlier in the call chain.","commonSituations":"Custom RPC servers invoking the impersonation check before authentication completes; test harnesses passing null; refactors that drop the getCurrentUser() call; doAs blocks where the proxy UGI was constructed incorrectly.","solutions":["Null-check the UserGroupInformation before calling authorize and fail authentication explicitly","Build the UGI properly: UserGroupInformation.createProxyUser(proxyUser, realUser) or UserGroupInformation.getCurrentUser()","In tests, create a remote UGI via UserGroupInformation.createRemoteUser(...) instead of null"],"exampleFix":"// before\nproxyUsers.authorize(user, remoteAddress); // user may be null\n\n// after\nif (user == null) {\n  throw new AuthenticationException(\"No authenticated user for impersonation check\");\n}\nproxyUsers.authorize(user, remoteAddress);","handlingStrategy":"validation","validationCode":"if (user == null) {\n  throw new AuthenticationException(\"Impersonation check requires an authenticated user\");\n}\nimpersonationProvider.authorize(user, remoteAddress);","typeGuard":"private static boolean isAuthorizableUgi(UserGroupInformation ugi) {\n  return ugi != null && ugi.getUserName() != null;\n}","tryCatchPattern":"try {\n  ProxyUsers.authorize(user, remoteAddress);\n} catch (IllegalArgumentException e) {\n  // caller bug: reject request, do not retry\n  throw new AuthenticationException(\"Malformed proxy request\", e);\n}","preventionTips":["Never call ProxyUsers.authorize before the connection is authenticated","Build UGIs with createRemoteUser/createProxyUser rather than passing variables that may be null","Add @NonNull assertions at RPC entry points"],"tags":["authorization","proxy-user","impersonation","null-check","hadoop"],"backgroundTag":"null-argument","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}