Problem/Motivation
A security review identified a low severity issue in exception handling. In src/Service/UserContactMappingService.php, exception messages from EntityStorageException are logged directly via $e->getMessage(). These messages may contain database details, file paths, or other system internals. Logging them directly could expose sensitive information in log files. The exceptions are also re-thrown, so callers may surface these messages to end users if not caught properly.
Affected locations:
src/Service/UserContactMappingService.php(lines 161-164): Contact creation failuresrc/Service/UserContactMappingService.php(lines 188-191): Mapping creation failure
Steps to reproduce
- Trigger a contact creation or mapping creation failure (e.g., constraint violation, database error)
- Check the Drupal log
- Observe that the full exception message is recorded, which may include system details
Proposed resolution
- Log a generic message for the error context; keep detailed exception message only in logs when appropriate
- Use Drupal's placeholder sanitization for any user-facing error messages
- Ensure callers catch exceptions and show generic messages to end users, not raw exception text
Remaining tasks
- Review and update
src/Service/UserContactMappingService.phpexception logging - Add inline comments documenting security considerations where applicable
- Manual testing of error scenarios
- Security review of changes
- Create merge request
- Code review
User interface changes
None. Error messages shown to users should remain generic.
API changes
None. This is an internal security hardening that doesn't change public APIs.
Data model changes
None.
Issue fork crm-3572858
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
bluegeek9 commentedComment #5
bluegeek9 commented