-
Notifications
You must be signed in to change notification settings - Fork 48
Add Security Check to Prevent User Enumeration #242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -519,7 +519,7 @@ public String superUserAuthenticate( | |||||
| response.setResponse(responseObj.toString()); | ||||||
| } catch (Exception e) { | ||||||
| logger.error("userAuthenticate failed with error " + e.getMessage(), e); | ||||||
| response.setError(5000, "Authentication failed. Please try again later."); // Generic fallback | ||||||
| response.setError(e); | ||||||
| } | ||||||
| logger.info("userAuthenticate response " + response.toString()); | ||||||
| return response.toString(); | ||||||
|
|
@@ -620,10 +620,10 @@ public String forgetPassword( | |||||
|
|
||||||
| if (mUsers == null || mUsers.size() <= 0) { | ||||||
| logger.error("User not found"); | ||||||
| throw new IEMRException("Request failed, please try again later"); | ||||||
| throw new IEMRException("If the username is valid, you will be asked a security question"); | ||||||
| } else if (mUsers.size() > 1) { | ||||||
| logger.error("More than 1 user found"); | ||||||
| throw new IEMRException("Request failed. Please retry again"); | ||||||
| throw new IEMRException("If the username is valid, you will be asked a security question"); | ||||||
|
|
||||||
| } else if (mUsers.size() == 1) { | ||||||
| List<Map<String, String>> quesAnsList = new ArrayList<>(); | ||||||
|
|
@@ -645,7 +645,7 @@ public String forgetPassword( | |||||
| } | ||||||
| } catch (Exception e) { | ||||||
| logger.error("forgetPassword failed with error " + e.getMessage(), e); | ||||||
| response.setError(5000, "ForgetPassword failed."); | ||||||
| response.setError(e); | ||||||
| } | ||||||
| logger.info("forgetPassword response " + response.toString()); | ||||||
| return response.toString(); | ||||||
|
|
@@ -734,7 +734,7 @@ public String changePassword( | |||||
| response.setResponse(changeReqResult); | ||||||
| } catch (Exception e) { | ||||||
| logger.error("changePassword failed with error " + e.getMessage(), e); | ||||||
| response.setError(5000, "Password change failed. Please try again later."); | ||||||
| response.setError(e); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security concern: Password operations should use generic error messages. Exposing detailed exception information in password change operations could reveal sensitive system details or validation logic to attackers. Consider using a generic error message: - response.setError(e);
+ response.setError(5000, "Unable to change password. Please try again later.");π€ Prompt for AI Agents |
||||||
| } | ||||||
| logger.info("changePassword response " + response.toString()); | ||||||
| return response.toString(); | ||||||
|
|
@@ -752,7 +752,7 @@ public String saveUserSecurityQuesAns( | |||||
| response.setResponse(responseData); | ||||||
| } catch (Exception e) { | ||||||
| logger.error("saveUserSecurityQuesAns failed with error " + e.getMessage(), e); | ||||||
| response.setError(5000, "Failed to save security questions. Please try again later."); | ||||||
| response.setError(e); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security concern: Security question operations should use generic error messages. Exposing detailed exception information in security question operations could reveal sensitive validation logic or system details. Consider using a generic error message: - response.setError(e);
+ response.setError(5000, "Unable to save security questions. Please try again later.");π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||
| } | ||||||
| logger.info("saveUserSecurityQuesAns response " + response.toString()); | ||||||
| return response.toString(); | ||||||
|
|
@@ -1058,7 +1058,7 @@ public String userAuthenticateByEncryption( | |||||
| response.setResponse(responseObj.toString()); | ||||||
| } catch (Exception e) { | ||||||
| logger.error("userAuthenticateByEncryption failed with error " + e.getMessage(), e); | ||||||
| response.setError(5000, "Request failed. Please try again."); | ||||||
| response.setError(e); | ||||||
| } | ||||||
| logger.info("userAuthenticateByEncryption response " + response.toString()); | ||||||
| return response.toString(); | ||||||
|
|
@@ -1076,7 +1076,7 @@ public String getrolewrapuptime(@PathVariable("roleID") Integer roleID) { | |||||
| } | ||||||
| response.setResponse(test.toString()); | ||||||
| } catch (Exception e) { | ||||||
| response.setError(5000, "Request failed. Please try again."); | ||||||
| response.setError(e); | ||||||
| } | ||||||
| return response.toString(); | ||||||
| } | ||||||
|
|
@@ -1104,7 +1104,7 @@ public String validateSecurityQuestionAndAnswer( | |||||
| throw new IEMRException("Invalid Request"); | ||||||
| } catch (Exception e) { | ||||||
| logger.error("validateSecurityQuestionAndAnswer failed: {}", e.toString()); | ||||||
| response.setError(5000, "Request failed. Please try again."); | ||||||
| response.setError(5000, e.getMessage()); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security concern: Exposing exception messages in security validation. While this retains the error code, exposing exception messages in security question validation could still reveal sensitive validation logic. Consider using a completely generic message: - response.setError(5000, e.getMessage());
+ response.setError(5000, "Security validation failed. Please try again.");π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||
| } | ||||||
| logger.info("validateSecurityQuestionAndAnswer API response" + response.toString()); | ||||||
| return response.toString(); | ||||||
|
|
@@ -1160,7 +1160,7 @@ public String userAuthenticateBhavya( | |||||
| response.setResponse(responseObj.toString()); | ||||||
| } catch (Exception e) { | ||||||
| logger.error("userAuthenticate failed with error " + e.getMessage(), e); | ||||||
| response.setError(5000, "Authentication failed. Please try again."); | ||||||
| response.setError(e); | ||||||
| } | ||||||
| logger.info("userAuthenticate response " + response.toString()); | ||||||
| return response.toString(); | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Security inconsistency: Generic error exposure undermines user enumeration prevention.
While the specific error cases above use proper generic messages, this catch-all exception handler now exposes detailed error information, which could still aid user enumeration attacks or expose sensitive system details.
Consider using a generic error message:
π€ Prompt for AI Agents