Skip to content
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

Add IPs address to the session #972

Merged
merged 2 commits into from
Jul 13, 2023
Merged

Conversation

fmarco76
Copy link
Member

The SSLEngine session "JSSSession" has been extended to container the IP addresses of the client and the server. These are used for the audit and have not other use in the protocol. By design the SSLEngine should be unaware of the underlying communication but this is need to keep the original audit format required for the certification.

@fmarco76
Copy link
Member Author

@edewata there are several missing dependencies during the build but I have not done any change on that. Are they related to the update done for Packit?

@ckelleyRH
Copy link
Contributor

@edewata there are several missing dependencies during the build but I have not done any change on that. Are they related to the update done for Packit?

Yes there is no pki build in the COPR at the minute (I'm working on it now). Interestingly, yours fails for the tomcat dependencies, and they are there 🤔

@fmarco76
Copy link
Member Author

yours fails for the tomcat dependencies,

This is strange. I have modified dependencies on tomcatjss but not here. It is better to verify what is the problem when the other problem are fixed

Comment on lines +337 to +343
public String getRemoteAddr() {
return remoteAddr;
}

public void setRemoteAddr(String remoteAddr) {
this.remoteAddr = remoteAddr;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class already has a peerHost. Should we just use that instead of adding a remoteAddr?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class already has a peerHost. Should we just use that instead of adding a remoteAddr?

The peerHost contains the hostname of the client and is assigned by JSSEngine. The audit has the IP addresses of client and server.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ladycfu Do we need to capture IP addresses specifically, or are hostnames fine too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the current version of pp says we are allowed to provide at least one of [IP Address, FQDN, user FQDN, or cert DN], however it also added that in the future, they will all be required.

@fmarco76 fmarco76 force-pushed the EventACCESSMissIP branch 2 times, most recently from fa24a5f to c28b0dc Compare June 30, 2023 15:06
@fmarco76
Copy link
Member Author

Additionally, the handshake failure would not fire the audit event because there was not invocation of checkSSLAerts() in case of an exception was caught during the unwrap.
Therefore the invocation of the check has been moved in order to be verified independently of the exceptions.

Copy link
Contributor

@ladycfu ladycfu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch for the missing checkSSLAlerts() call!

Comment on lines 1265 to 1269
if (seen_exception == false && ssl_exception == null) {
ssl_exception = checkSSLAlerts();
seen_exception = (ssl_exception != null);
SSLException checkException = checkSSLAlerts();
if (checkException != null && !seen_exception) {
ssl_exception = checkException;
seen_exception = ssl_exception != null;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really familiar with this code, but it looks like the original code would check for SSL alerts then stop checking once it has seen an exception, and the new code will always check for SSL alerts but discard all exceptions after the first one. Is that the intended change?

I think the new code can be simplified like this:

SSLException checkException = checkSSLAlerts();
if (checkException != null && !seen_exception) {
    ssl_exception = checkException;
    seen_exception = true;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really familiar with this code, but it looks like the original code would check for SSL alerts then stop checking once it has seen an exception, and the new code will always check for SSL alerts but discard all exceptions after the first one. Is that the intended change?

The problem with the previous code was that if an exception raise here the method checkSSLAlerts() is never invoked and TLS alerts are not propagated (and audit are not written). With this change it is invoked in any case but the first error is reported.

Copy link
Contributor

@edewata edewata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one question due to a possible redundancy, but no objections if that's required to fix the issue. I'll defer to @ladycfu and @jmagne for merging. I suppose the more critical changes are in tomcatjss/pull/73.

The SSLEngine session "JSSSession" has been extended to container the IP
addresses of the client and the server. These are used for the audit and
have not other use in the protocol. By design the SSLEngine should be
unaware of the underlying communication but this is need to keep the
original audit format required for the certification.
When the handshake failure event fails it should fire an audit event for
ACCESS_SESSION_ESTABLISH with the details (IPs, outcome, description,
...).

These event were never fired because in case of handshake error the
input stream is unwrapped until the end and output stream is wrapped
and data sent to the peer, then closed together. All this without
checking if TLS event were present in the stream.

The code is fixed and now the check for event is done on any error and
the first one is reported.
@sonarcloud
Copy link

sonarcloud bot commented Jul 13, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@fmarco76 fmarco76 merged commit 7be60d6 into dogtagpki:master Jul 13, 2023
@fmarco76 fmarco76 deleted the EventACCESSMissIP branch August 1, 2023 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants