Cyberduck Mountain Duck CLI

Opened 8 years ago

Closed 6 years ago

Last modified 5 years ago

#5087 closed enhancement (fixed)

Reuse Session key on data connection

Reported by: abrax5 Owned by: dkocher
Priority: low Milestone: 4.3
Component: ftp-tls Version: 3.5.1
Severity: normal Keywords: proftpd
Cc: Architecture: Intel
Platform: Mac OS X 10.6

Description (last modified by dkocher)

I saw that it's described as a known issue in the Wiki, but still, could this be implemented?

From the ProFTPd documentation (http://www.proftpd.org/docs/contrib/mod_tls.html)

  • NoSessionReuseRequired
    As of ProFTPD 1.3.3rc1, mod_tls only accepts SSL/TLS data connections that reuse the SSL session of the control connection, as a security measure. Unfortunately, there are some clients (e.g. curl) which do not reuse SSL sessions.
    

I see this incompatibility with my Debian ProFTPd 1.3.3a.

Thanks

Change History (26)

comment:1 Changed 8 years ago by dkocher

  • Component changed from core to ftp-tls
  • Description modified (diff)

comment:2 Changed 8 years ago by dkocher

The issue is that our SSL session cache is by both host and port number. Using PASV to initiate the download will give a different port number than the control connection on port 21 and therefore uses a new SSL session context.

comment:3 follow-up: Changed 8 years ago by abrax5

Thanks for your feedback. Haven't looked at the code myself, but couldn't we retrieve and clone the session key from the cache and create a new related entry in the session cache instead of doing a renegotiation? I guess at the time of creating the new connection for the download it's still known what the related control connection is.

comment:4 in reply to: ↑ 3 Changed 8 years ago by dkocher

Replying to abrax5:

Thanks for your feedback. Haven't looked at the code myself, but couldn't we retrieve and clone the session key from the cache and create a new related entry in the session cache instead of doing a renegotiation? I guess at the time of creating the new connection for the download it's still known what the related control connection is.

The session caching is in a private class in the sun.security package I cannot access.

Last edited 8 years ago by dkocher (previous) (diff)

comment:5 Changed 8 years ago by dkocher

Issue is documented in the wiki.

comment:6 Changed 8 years ago by dkocher

Cross referencing to bug reports in thirdparty software:

comment:7 follow-up: Changed 8 years ago by abrax5

I looked at GNU classpath, and there's a file called ClientHandshake.java:

            case WRITE_CLIENT_HELLO:
            {
              ClientHelloBuilder hello = new ClientHelloBuilder();
              AbstractSessionContext ctx = (AbstractSessionContext)
                engine.contextImpl.engineGetClientSessionContext();
              continued = (SessionImpl) ctx.getSession(engine.getPeerHost(),
                                                       engine.getPeerPort());

Maybe Cyberduck could use a modified version of GNU classpath for this use case and modify the AbstractSessionContext implementation so that it returns a previously used session for the same host even though the port is different?

Last edited 8 years ago by abrax5 (previous) (diff)

comment:8 follow-up: Changed 8 years ago by abrax5

I'm not really that familiar with Java, but looking at this: http://download.oracle.com/javase/6/docs/api/javax/net/ssl/SSLContext.html

The protected constructor for an SSLContext allows you to specify an SSLContextSpi. Maybe we could override SSLContext implementation with one that uses an SSLContextSpi derived from the default one, that just differs in what it would return for engineGetClientSessionContext(). This method returns an SSLSessionContext which allows enumerating SessionIDs.

These are just some rough ideas, but may through this path we could tell the TLS engine to try reusing a session. We don't really need access to the masterSecret of the session, I think. We just need to make sure that the TLS engine can find the old ID and advertise the reuse ID to the server in the CLIENT_HELLO msg.

comment:9 in reply to: ↑ 7 Changed 8 years ago by dkocher

Replying to abrax5:

I looked at GNU classpath, and there's a file called ClientHandshake.java:

            case WRITE_CLIENT_HELLO:
            {
              ClientHelloBuilder hello = new ClientHelloBuilder();
              AbstractSessionContext ctx = (AbstractSessionContext)
                engine.contextImpl.engineGetClientSessionContext();
              continued = (SessionImpl) ctx.getSession(engine.getPeerHost(),
                                                       engine.getPeerPort());

Maybe Cyberduck could use a modified version of GNU classpath for this use case and modify the AbstractSessionContext implementation so that it returns a previously used session for the same host even though the port is different?

Yes, the peer port is what is causing a new session being created. The solution must somehow overwrite the peer port.

comment:10 in reply to: ↑ 8 Changed 8 years ago by dkocher

Replying to abrax5:

We have a problem delegating to the default context because everything has protected access. Also a new SSLContext is created using the factory method getInstance. Have to dig further.

comment:11 follow-ups: Changed 8 years ago by abrax5

In OpenJDK, this code is in ClientHandshaker.java: (from http://download.java.net/openjdk/jdk6/)

    HandshakeMessage getKickstartMessage() throws SSLException {
        ClientHello mesg = new ClientHello(sslContext.getSecureRandom(),
                                        protocolVersion);
        maxProtocolVersion = protocolVersion;

        clnt_random = mesg.clnt_random;

        //
        // Try to resume an existing session.  This might be mandatory,
        // given certain API options.
        //
        session = ((SSLSessionContextImpl)sslContext
                        .engineGetClientSessionContext())
                        .get(getHostSE(), getPortSE());

So it'd be really useful if we can hook in there to replace the SSLSessionContext with our own implementation.

comment:12 in reply to: ↑ 11 Changed 8 years ago by dkocher

Replying to abrax5:

In OpenJDK, this code is in ClientHandshaker.java: (from http://download.java.net/openjdk/jdk6/)

Yes, that is what I meant above that the relevant code is in sun.security. We would need to replace a very large part of the JDK with custom implementations if we want to replace that implementation.

comment:13 Changed 8 years ago by dkocher

Because of the proposal to switch to a secure connection if the server advertises AUTH TLS in its features, this has become a major issue for many. See #5168.

comment:14 Changed 8 years ago by dkocher

Added configuration note to wiki.

comment:15 Changed 8 years ago by dkocher

#5285 closed as duplicate.

comment:16 Changed 8 years ago by dkocher

  • Priority changed from normal to high

comment:17 Changed 8 years ago by dkocher

A workaround if the server allows would be to open the data socket without TLS. Uncheck Try to use TLS for data channel in Preferences → FTP → Data Channel Security.

comment:18 in reply to: ↑ 11 Changed 8 years ago by dkocher

Replying to abrax5:

In OpenJDK, this code is in ClientHandshaker.java

Let me know if you have found any resolution for this. I am clueless how this could be best achieved.

comment:19 Changed 8 years ago by dkocher

#5484 closed as duplicate.

comment:20 Changed 8 years ago by dkocher

  • Type changed from enhancement to defect

comment:21 Changed 8 years ago by dkocher

#5658 closed as duplicate.

comment:22 Changed 7 years ago by dkocher

Blocked by NET-408.

comment:23 Changed 7 years ago by dkocher

#6027 closed as duplicate.

comment:24 Changed 6 years ago by dkocher

  • Priority changed from high to low
  • Summary changed from Reuse Session key on Data connection to Reuse Session key on data connection
  • Type changed from defect to enhancement

comment:25 Changed 6 years ago by dkocher

  • Milestone set to 4.2.2
  • Resolution set to fixed
  • Status changed from new to closed

In r10760.

comment:26 Changed 5 years ago by dkocher

Addendum in r10836.

Note: See TracTickets for help on using tickets.
swiss made software