Skip to content

secure cookie fails penetration tests #6767

Closed

Description

@mzeyrek

Steps to reproduce

1.test SSL nextcloud server at https://pentest-tools.com/website-vulnerability-scanning/web-server-scanner?run
2.getting medium security due secure cookie not implemented
3. nextcloud is running under dedicated domain, not subdomain.

Expected behaviour

Penetration test to pass as SameSiteCookieMiddleware.php seems to handle request

Actual behaviour

sending cookies via http without secure flag in https.
More details : https://help.nextcloud.com/t/secure-cookie-implementation/21854/3

Server configuration

Operating system: Debian 9 Stretch
Web server: nginx/1.10.3
Database: MariaDB 10.2
PHP version: 7.0
Nextcloud version: (see Nextcloud admin page) 12.0.3

Activity

  1. rullzer commented on Oct 5, 2017

    @rullzer
    Member
  2. e-alfred commented on Oct 5, 2017

    @e-alfred

    Openvas also produces a medium warning with this content for an instance not running in a subdirectory:

    Summary
    
    The host is running a server with SSL/TLS and is prone to information disclosure vulnerability.
    Vulnerability Detection Result
    
    The cookies:
    
    Set-Cookie: 45342agfd4=replaced; path=/; HttpOnly
    
    are missing the “secure” attribute.
    
    Solution
    
    Solution type: Mitigation Mitigation
    
    Set the ‘secure’ attribute for any cookies that are sent over a SSL/TLS connection.
    Affected Software/OS
    
    Server with SSL/TLS.
    Vulnerability Insight
    
    The flaw is due to cookie is not using ‘secure’ attribute, which allows cookie to be passed to the server by the client over non-secure channels (http) and allows attacker to conduct session hijacking attacks.
    
    Impact Level: Application
    Vulnerability Detection Method
    
    Details: SSL/TLS: Missing secure Cookie Attribute (OID: 1.3.6.1.4.1.25623.1.0.902661)
    
    Version used: $Revision: 5543 $
    
    References
    
    Other:
    https://www.owasp.org/index.php/SecureFlag2
    http://www.ietf.org/rfc/rfc2965.txt
    https://www.owasp.org/index.php/Testing_for_cookies_attributes_(OWASP-SM-002)
    
  3. LukasReschke commented on Oct 5, 2017

    @LukasReschke
    Member

    The secure flag is applied as soon as you log-in. There's not really a security issue here thus.

  4. jomo commented on Nov 19, 2018

    @jomo

    Unfortunately this does not seem to be true, @LukasReschke.

    image

    I've double checked with Firefox' "Storage" inspector and all cookies are marked as "Secure: false".

  5. rullzer commented on Nov 20, 2018

    @rullzer
    Member

    @jomo did you by any chance first access the site via plain http?
    I can't trigger this otherwise.

  6. jomo commented on Nov 20, 2018

    @jomo

    That comment pointed me in the right direction. TLS termination is done by nginx, I should have thought of that…

    I had to add this to the config.php:

    'overwriteprotocol' => 'https'

    Can confirm it's working now, thanks!

  7. jomo commented on Nov 20, 2018

    @jomo

    In fact, the cookies are sent as secure even before login.

    See observatory.mozilla.org report:
    screenshot

    Guess this issue can be closed?

  8. pgera commented on Jan 13, 2019

    @pgera

    I just had to do this for my docker nextcloud setup. At least in my case (and I'm assuming for others too), tls is done by the nginx docker container. As a result, this test as well as the __host prefix test on scan.nextcloud.com were failing. I suppose this should be addressed on the docker-nextcloud repo as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions