nextcloud / nextcloud/user_saml

Cannot modify header information - headers already sent

Open
#689 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
104
Forks
85
Avg merge
1d 15h
Merged PRs (30d)
16

Description

On NC 24.0.8, with latest app version (5.1.2):

{
  "reqId": "rwC2CbWZ4phfcLjQujFW",
  "level": 3,
  "time": "2023-01-13T13:51:29+01:00",
  "remoteAddr": "27.11.2.18",
  "user": "--",
  "app": "PHP",
  "method": "POST",
  "url": "/apps/user_saml/saml/acs",
  "message": "Cannot modify header information - headers already sent by (output started at /var/www/nextcloud/apps/user_saml/3rdparty/vendor/onelogin/php-saml/src/Saml2/Response.php:452) at /var/www/nextcloud/lib/private/AppFramework/Http/Output.php#70",
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36",
  "version": "24.0.8.2",
  "exception": {
    "Exception": "Error",
    "Message": "Cannot modify header information - headers already sent by (output started at /var/www/nextcloud/apps/user_saml/3rdparty/vendor/onelogin/php-saml/src/Saml2/Response.php:452) at /var/www/nextcloud/lib/private/AppFramework/Http/Output.php#70",
    "Code": 0,
    "Trace": [
      {
        "function": "onAll",
        "class": "OC\\Log\\ErrorHandler",
        "type": "::",
        "args": [
          2,
          "Cannot modify header information - headers already sent by (output started at /var/www/nextcloud/apps/user_saml/3rdparty/vendor/onelogin/php-saml/src/Saml2/Response.php:452)",
          "/var/www/nextcloud/lib/private/AppFramework/Http/Output.php",
          70
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/Http/Output.php",
        "line": 70,
        "function": "header",
        "args": [
          "Content-Length: 0"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/App.php",
        "line": 231,
        "function": "setHeader",
        "class": "OC\\AppFramework\\Http\\Output",
        "type": "->",
        "args": [
          "Content-Length: 0"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Route/Router.php",
        "line": 298,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::",
        "args": [
          "OCA\\User_SAML\\Controller\\SAMLController",
          "assertionConsumerService",
          {
            "__class__": "OC\\AppFramework\\DependencyInjection\\DIContainer"
          },
          [
            "user_saml.SAML.assertionConsumerService"
          ]
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/base.php",
        "line": 1030,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->",
        "args": [
          "/apps/user_saml/saml/acs"
        ]
      },
      {
        "file": "/var/www/nextcloud/index.php",
        "line": 36,
        "function": "handleRequest",
        "class": "OC",
        "type": "::",
        "args": []
      }
    ],
    "File": "/var/www/nextcloud/lib/private/Log/ErrorHandler.php",
    "Line": 99,
    "CustomMessage": "--"
  },
  "id": "63c154ce1fe4a"
}

followed by

{
  "reqId": "VOObLzEFXnm13RmPqfmB",
  "level": 3,
  "time": "2023-01-13T13:51:49+01:00",
  "remoteAddr": "21.17.2.18",
  "user": "--",
  "app": "PHP",
  "method": "GET",
  "url": "/apps/user_saml/saml/sls?requesttoken=bf9JX1DN2xR4opGtLR73N9/iX9nEJKRVw12W3GP9X7w%3D:W7kNNj6EriJL9efufUyTda%2BTa%2BzrXsAMihmhkwCJD%2Bk%3D",
  "message": "session_start(): Ignoring session_start() because a session is already active at /var/www/nextcloud/lib/private/Session/Internal.php#208",
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36",
  "version": "24.0.8.2",
  "exception": {
    "Exception": "Error",
    "Message": "session_start(): Ignoring session_start() because a session is already active at /var/www/nextcloud/lib/private/Session/Internal.php#208",
    "Code": 0,
    "Trace": [
      {a
        "function": "onAll",
        "class": "OC\\Log\\ErrorHandler",
        "type": "::",
        "args": [
          8,
          "session_start(): Ignoring session_start() because a session is already active",
          "/var/www/nextcloud/lib/private/Session/Internal.php",
          208
        ]
      },
      {
        "function": "session_start",
        "args": [
          [
            "Lax"
          ]
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Session/Internal.php",
        "line": 208,
        "function": "call_user_func_array",
        "args": [
          "session_start",
          [
            [
              "Lax"
            ]
          ]
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Session/Internal.php",
        "line": 218,
        "function": "invoke",
        "class": "OC\\Session\\Internal",
        "type": "->",
        "args": [
          "session_start",
          [
            [
              "Lax"
            ]
          ],
          true
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Session/Internal.php",
        "line": 106,
        "function": "startSession",
        "class": "OC\\Session\\Internal",
        "type": "->",
        "args": [
          true
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Session/CryptoSessionData.php",
        "line": 149,
        "function": "clear",
        "class": "OC\\Session\\Internal",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/nextcloud/lib/private/User/Session.php",
        "line": 939,
        "function": "clear",
        "class": "OC\\Session\\CryptoSessionData",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/nextcloud/apps/user_saml/lib/Controller/SAMLController.php",
        "line": 495,
        "function": "logout",
        "class": "OC\\User\\Session",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 225,
        "function": "singleLogoutService",
        "class": "OCA\\User_SAML\\Controller\\SAMLController",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 133,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          {
            "__class__": "OCA\\User_SAML\\Controller\\SAMLController"
          },
          "singleLogoutService"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/App.php",
        "line": 172,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          {
            "__class__": "OCA\\User_SAML\\Controller\\SAMLController"
          },
          "singleLogoutService"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Route/Router.php",
        "line": 298,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::",
        "args": [
          "OCA\\User_SAML\\Controller\\SAMLController",
          "singleLogoutService",
          {
            "__class__": "OC\\AppFramework\\DependencyInjection\\DIContainer"
          },
          [
            "user_saml.SAML.singleLogoutService"
          ]
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/base.php",
        "line": 1030,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->",
        "args": [
          "/apps/user_saml/saml/sls"
        ]
      },
      {
        "file": "/var/www/nextcloud/index.php",
        "line": 36,
        "function": "handleRequest",
        "class": "OC",
        "type": "::",
        "args": []
      }
    ],
    "File": "/var/www/nextcloud/lib/private/Log/ErrorHandler.php",
    "Line": 99,
    "CustomMessage": "--"
  },
  "id": "63c154ce1fe1d"
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the SAML ACS and SLS flows in apps/user_saml/lib/Controller/SAMLController.php, especially the locations shown in the logs, and inspect the referenced session and output classes. Reproduce the reported login/logout requests and determine whether the headers-already-sent and already-active-session warnings still occur; done means both flows complete without these warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
authentication, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.