InvalidArgumentException: Given IP address can't be parsed with link-local address after update to 30.0.1.2

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 29.0.5): 30.0.1.2
Operating system and version (eg, Ubuntu 24.04): Arch (latest)
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.62
PHP version (eg, 8.3): PHP 8.3.13 (cli) (built: Oct 23 2024 07:04:22) (NTS)

The issue you are facing:

After updating to 30.0.1.2 I can’t make any request to Nextcloud when accessing it through LAN with ipv6 when using link-local address: it causes ArgumentException: Given IP address can’t be parsed. For example, it is accessible via http://localhost, but via http://my-host.local it breaks with error.

Address was fe80::1fc4:15d8:78db:2319%enp4s0. Seems that interface suffix (%enp4s0) causes this error.

There was no such issue before (I don’t remember what version I had before, maybe 29.0.8.1, according to previous entries in updater.log)

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Update to 30.0.1.2 with web-based updater.
  2. Open Nextcloud web UI from address that causes it to be requested from link-local ipv6 address

The output of your Nextcloud log in Admin > Logging:

Error	core	
InvalidArgumentException Given IP address can’t be parsed
Exception thrown: InvalidArgumentException
Oct 28, 2024, 6:22:16 PM

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'ocgqsrv0aj8b',
  'passwordsalt' => '...',
  'secret' => '...',
  'trusted_domains' =>
  array (
    0 => 'localhost:8083',
    1 => '192.168.1.2:8083',
    2 => 'my-host.local:8083',
  ),
  'datadirectory' => '/srv/http/nextcloud/data',
  'dbtype' => 'sqlite3',
  'version' => '30.0.1.2',
  'overwrite.cli.url' => 'http://my-host.local:8083/nextcloud',
  'htaccess.RewriteBase' => '/nextcloud',
  'installed' => true,
  'maintenance' => false,
  'theme' => '',
  'overwritehost' => 'my-host-local:8083',
  'enabledPreviewProviders' =>
  array (
    0 => 'OC\\Preview\\MP3',
    1 => 'OC\\Preview\\TXT',
    2 => 'OC\\Preview\\MarkDown',
    3 => 'OC\\Preview\\OpenDocument',
    4 => 'OC\\Preview\\Krita',
    5 => 'OC\\Preview\\Movie',
    6 => 'OC\\Preview\\Imaginary',
  ),
  'preview_imaginary_url' => 'http://localhost:8088',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'noreply',
  'mail_domain' => '...',
  'mail_smtphost' => '...',
  'default_phone_region' => '...',
  'preview_max_x' => 2048,
  'preview_max_y' => 2048,
  'preview_max_memory' => -1,
  'preview_max_filesize_image' => -1,
  'jpeg_quality' => '60',
  'trashbin_retention_obligation' => 'auto, 7',
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud.log',
  'loglevel' => 3,
  'data-fingerprint' => '...',
  'updater.secret' => '...',
);

The output of your Apache/nginx/system log in /var/log/____:

[Mon Oct 28 17:38:48.457914 2024] [mpm_event:notice] [pid 210359:tid 210359] AH00489: Apache/2.4.62 (Unix) mod_fcgid/2.3.9 configured -- resuming normal operations
[Mon Oct 28 17:38:48.457987 2024] [core:notice] [pid 210359:tid 210359] AH00094: Command line: '/usr/bin/httpd -D FOREGROUND'

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

{
    "reqId": "8MlnLm9j5ORIyE470mxq",
    "level": 3,
    "time": "2024-10-28T15:04:34+00:00",
    "remoteAddr": "fe80::1fc4:15d8:78db:2319%enp4s0",
    "user": "--",
    "app": "core",
    "method": "GET",
    "url": "/nextcloud/",
    "message": "Exception thrown: InvalidArgumentException",
    "userAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:131.0) Gecko/20100101 Firefox/131.0",
    "version": "30.0.1.2",
    "exception": {
        "Exception": "InvalidArgumentException",
        "Message": "Given IP address can\u2019t be parsed",
        "Code": 0,
        "Trace": [
            {
                "file": "/srv/http/nextcloud/lib/private/Security/Ip/RemoteAddress.php",
                "line": 30,
                "function": "__construct",
                "class": "OC\\Security\\Ip\\Address",
                "type": "->"
            },
            {
                "function": "__construct",
                "class": "OC\\Security\\Ip\\RemoteAddress",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 61,
                "function": "newInstanceArgs",
                "class": "ReflectionClass",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 106,
                "function": "buildClass",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 124,
                "function": "resolve",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/ServerContainer.php",
                "line": 155,
                "function": "query",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 42,
                "function": "query",
                "class": "OC\\ServerContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 175,
                "function": "get",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 153,
                "function": "OC\\AppFramework\\Utility\\{closure}",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->",
                "args": [
                    "*** sensitive parameters replaced ***"
                ]
            },
            {
                "file": "/srv/http/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php",
                "line": 118,
                "function": "OC\\AppFramework\\Utility\\{closure}",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->",
                "args": [
                    "*** sensitive parameters replaced ***"
                ]
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 120,
                "function": "offsetGet",
                "class": "Pimple\\Container",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/ServerContainer.php",
                "line": 155,
                "function": "query",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 42,
                "function": "query",
                "class": "OC\\ServerContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/Server.php",
                "line": 469,
                "function": "get",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 153,
                "function": "OC\\{closure}",
                "class": "OC\\Server",
                "type": "->",
                "args": [
                    "*** sensitive parameters replaced ***"
                ]
            },
            {
                "file": "/srv/http/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php",
                "line": 122,
                "function": "OC\\AppFramework\\Utility\\{closure}",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->",
                "args": [
                    "*** sensitive parameters replaced ***"
                ]
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 120,
                "function": "offsetGet",
                "class": "Pimple\\Container",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/ServerContainer.php",
                "line": 155,
                "function": "query",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 42,
                "function": "query",
                "class": "OC\\ServerContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/Server.php",
                "line": 859,
                "function": "get",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 153,
                "function": "OC\\{closure}",
                "class": "OC\\Server",
                "type": "->",
                "args": [
                    "*** sensitive parameters replaced ***"
                ]
            },
            {
                "file": "/srv/http/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php",
                "line": 122,
                "function": "OC\\AppFramework\\Utility\\{closure}",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->",
                "args": [
                    "*** sensitive parameters replaced ***"
                ]
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 120,
                "function": "offsetGet",
                "class": "Pimple\\Container",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/ServerContainer.php",
                "line": 155,
                "function": "query",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 42,
                "function": "query",
                "class": "OC\\ServerContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 175,
                "function": "get",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 153,
                "function": "OC\\AppFramework\\Utility\\{closure}",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->",
                "args": [
                    "*** sensitive parameters replaced ***"
                ]
            },
            {
                "file": "/srv/http/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php",
                "line": 118,
                "function": "OC\\AppFramework\\Utility\\{closure}",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->",
                "args": [
                    "*** sensitive parameters replaced ***"
                ]
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 120,
                "function": "offsetGet",
                "class": "Pimple\\Container",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/ServerContainer.php",
                "line": 155,
                "function": "query",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 42,
                "function": "query",
                "class": "OC\\ServerContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/Server.php",
                "line": 617,
                "function": "get",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 153,
                "function": "OC\\{closure}",
                "class": "OC\\Server",
                "type": "->",
                "args": [
                    "*** sensitive parameters replaced ***"
                ]
            },
            {
                "file": "/srv/http/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php",
                "line": 122,
                "function": "OC\\AppFramework\\Utility\\{closure}",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->",
                "args": [
                    "*** sensitive parameters replaced ***"
                ]
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 120,
                "function": "offsetGet",
                "class": "Pimple\\Container",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/ServerContainer.php",
                "line": 155,
                "function": "query",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
                "line": 42,
                "function": "query",
                "class": "OC\\ServerContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/Server.php",
                "line": 1706,
                "function": "get",
                "class": "OC\\AppFramework\\Utility\\SimpleContainer",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/legacy/OC_Template.php",
                "line": 49,
                "function": "getL10N",
                "class": "OC\\Server",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/lib/private/legacy/OC_Template.php",
                "line": 285,
                "function": "__construct",
                "class": "OC_Template",
                "type": "->"
            },
            {
                "file": "/srv/http/nextcloud/index.php",
                "line": 89,
                "function": "printExceptionErrorPage",
                "class": "OC_Template",
                "type": "::"
            }
        ],
        "File": "/srv/http/nextcloud/lib/private/Security/Ip/Address.php",
        "Line": 26,
        "CustomMessage": "Exception thrown: InvalidArgumentException"
    }
}

Hi,

after updating to Nextcloud 30.0.1.2 my log was also flooded with the same error message …

After investigating this error I’ve found out that the problem seems to be the network interface (everything after %-sign) of IPv6. The IP-Lib library probably has parsing problems with IPv6 if it contains network interfaces.

As a workaround I’m currently removing the network interface before parsing address string.

In file lib/private/Security/Ip/Address.php replace line 24 containing
$ip = Factory::parseAddressString($ip);
with the following line of code
$ip = Factory::parseAddressString(preg_replace('~%.*$~', '', $ip));

This will remove all network interfaces at the end of string and so IP-Lib is happy …
Hope this helps :slight_smile:

ariaci

Fix pending in fix(net/security): Handle IPv6 zone IDs in link-local addresses by joshtrichards · Pull Request #49039 · nextcloud/server · GitHub.

If you’re able, test the more extensive change in that PR. Keep in mind it’s fresh and un-merged so further changes may be made.

I’m surprised this hasn’t been reported before, though it does only impact link-local addresses.

Feel free to try this: https://github.com/nextcloud/server/pull/49038

Should work and use iplib as designed.

Edit: Supserseded by fix(net/security): Handle IPv6 zone IDs in link-local addresses by joshtrichards · Pull Request #49039 · nextcloud/server · GitHub

Applied patch from PR 49038 (seems that 49039 has the same changes) to my local install and it works.

Hah. Indeed. @MartB and I seem to have both submitted a fix within minutes of each other.