SFTP external storage access not working | RuntimeException: Invalid size

Hi I have upgraded the owncloud from 10.6.5 to 10.7.0 and my external storage access of SFTP is not connecting showing like runtime exception of invalid size

Server configuration

Operating system: Ubuntu 18.04lts

**Web server:**apache 2

Database: MYSQL

**PHP version:**PHP 7.2

ownCloud version: owncloud 10.7.0

Updated from an older ownCloud or fresh install: older owncloud from 10.6.5 to 10.7.0

Where did you install ownCloud from: Repository

Signing status (ownCloud 9.0 and above):

Login as admin user into your ownCloud and access 
http://example.com/index.php/settings/integrity/failed 
paste the results into https://gist.github.com/ and puth the link here.

No errors has been found

The content of config/config.php:

sudo -u www-data php occ config:list system
“system”: {
“instanceid”: “ocprnexb1mxl”,
“passwordsalt”: “REMOVED SENSITIVE VALUE”,
“secret”: “REMOVED SENSITIVE VALUE”,
“trusted_domains”: [
“192.168.1.2”,
"domain.group”,
“192.168.1.4”,
“Public ip”
],
“datadirectory”: “/var/www/html/owncloud/data”,
“overwrite.cli.url”: “http://192.168.1.5/owncloud”,
“dbtype”: “mysql”,
“version”: “10.7.0.4”,
“logtimezone”: “UTC”,
“apps_paths”: [
{
“path”: “/var/www/html/owncloud/apps”,
“url”: “/apps”,
“writable”: false
},
{
“path”: “/var/www/html/owncloud/apps-external”,
“url”: “/apps-external”,
“writable”: true
}
],
“installed”: true,
“maintenance”: false,
“loglevel”: 1,
“dbname”: “owncloud”,
“dbhost”: “127.0.0.1”,
“dbuser”: “REMOVED SENSITIVE VALUE”,
“dbpassword”: “REMOVED SENSITIVE VALUE”,
“updater.secret”: “REMOVED SENSITIVE VALUE”
}
}

List of activated apps:

If you have access to your command line run e.g.:
sudo -u www-data php occ app:list
Enabled:
  - activity:
    - Version: 2.6.0
    - Path: /var/www/html/owncloud/apps-external/activity
  - announcementcenter:
    - Version: 1.2.1
    - Path: /var/www/html/owncloud/apps-external/announcementcenter
  - bookmarks:
    - Version: 0.10.6
    - Path: /var/www/html/owncloud/apps-external/bookmarks
  - calendar:
    - Version: 1.6.4
    - Path: /var/www/html/owncloud/apps-external/calendar
  - comments:
    - Version: 0.3.0
    - Path: /var/www/html/owncloud/apps/comments
  - configreport:
    - Version: 0.2.0
    - Path: /var/www/html/owncloud/apps/configreport
  - customgroups:
    - Version: 0.6.1
    - Path: /var/www/html/owncloud/apps-external/customgroups
  - dav:
    - Version: 0.6.0
    - Path: /var/www/html/owncloud/apps/dav
  - diagnostics:
    - Version: 0.1.4
    - Path: /var/www/html/owncloud/apps-external/diagnostics
  - external:
    - Version: 1.4.0
    - Path: /var/www/html/owncloud/apps/external
  - federatedfilesharing:
    - Version: 0.5.0
    - Path: /var/www/html/owncloud/apps/federatedfilesharing
  - federation:
    - Version: 0.1.0
    - Path: /var/www/html/owncloud/apps/federation
  - files:
    - Version: 1.5.2
    - Path: /var/www/html/owncloud/apps/files
  - files_clipboard:
    - Version: 1.0.3
    - Path: /var/www/html/owncloud/apps-external/files_clipboard
  - files_external:
    - Version: 0.7.1
    - Path: /var/www/html/owncloud/apps/files_external
  - files_external_ftp:
    - Version: 0.2.1
    - Path: /var/www/html/owncloud/apps-external/files_external_ftp
  - files_mediaviewer:
    - Version: 1.0.4
    - Path: /var/www/html/owncloud/apps/files_mediaviewer
  - files_pdfviewer:
    - Version: 0.12.1
    - Path: /var/www/html/owncloud/apps-external/files_pdfviewer
  - files_sharing:
    - Version: 0.14.0
    - Path: /var/www/html/owncloud/apps/files_sharing
  - files_texteditor:
    - Version: 2.3.1
    - Path: /var/www/html/owncloud/apps-external/files_texteditor
  - files_textviewer:
    - Version: 1.0.3
    - Path: /var/www/html/owncloud/apps-external/files_textviewer
  - files_trashbin:
    - Version: 0.9.1
    - Path: /var/www/html/owncloud/apps/files_trashbin
  - files_versions:
    - Version: 1.3.0
    - Path: /var/www/html/owncloud/apps/files_versions
  - firstrunwizard:
    - Version: 1.2.0
    - Path: /var/www/html/owncloud/apps/firstrunwizard
  - impersonate:
    - Version: 0.5.0
    - Path: /var/www/html/owncloud/apps-external/impersonate
  - market:
    - Version: 0.6.0
    - Path: /var/www/html/owncloud/apps/market
  - nextbackup:
    - Version: 21.1.1
    - Path: /var/www/html/owncloud/apps-external/nextbackup
  - notes:
    - Version: 2.0.6
    - Path: /var/www/html/owncloud/apps-external/notes
  - notifications:
    - Version: 0.5.2
    - Path: /var/www/html/owncloud/apps/notifications
  - oauth2:
    - Version: 0.4.4
    - Path: /var/www/html/owncloud/apps-external/oauth2
  - onlyoffice:
    - Version: 6.4.3
    - Path: /var/www/html/owncloud/apps-external/onlyoffice
  - provisioning_api:
    - Version: 0.5.0
    - Path: /var/www/html/owncloud/apps/provisioning_api
  - richdocuments:
    - Version: 2.5.0
    - Path: /var/www/html/owncloud/apps-external/richdocuments
  - search_elastic:
    - Version: 1.0.0
    - Path: /var/www/html/owncloud/apps-external/search_elastic
  - sensorlogger:
    - Version: 0.1.0.1
    - Path: /var/www/html/owncloud/apps-external/sensorlogger
  - systemtags:
    - Version: 0.3.0
    - Path: /var/www/html/owncloud/apps/systemtags
  - tasks:
    - Version: 0.9.7
    - Path: /var/www/html/owncloud/apps-external/tasks
  - updatenotification:
    - Version: 0.2.1
    - Path: /var/www/html/owncloud/apps/updatenotification
  - user_external:
    - Version: 0.6.0
    - Path: /var/www/html/owncloud/apps/user_external
  - wallpaper:
    - Version: 0.2.2
    - Path: /var/www/html/owncloud/apps-external/wallpaper
  - web:
    - Version: 1.0.2
    - Path: /var/www/html/owncloud/apps-external/web
Disabled:
  - encryption:
    - Path: /var/www/html/owncloud/apps/encryption
  - openidconnect:
    - Path: /var/www/html/owncloud/apps-external/openidconnect

**Are you using external storage, if yes which one:** local/smb/sftp/... Yes SFTP

**Are you using encryption:** no

**Are you using an external user-backend, if yes which one:** LDAP/ActiveDirectory/Webdav/... NO


### Client configuration
**Browser:**

**Operating system:**


#### ownCloud log (data/owncloud.log)
6/19/21
10:28:30.000 AM	{ [-]
   app: files_external
   level: 3
   message: Exception: {"Exception":"RuntimeException","Message":"Invalid size","Code":0,"Trace":"#0 \/var\/www\/html\/owncloud\/apps\/files_external\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Net\/SSH2.php(3283): phpseclib3\\Net\\SSH2->read_remaining_bytes(1044)\n#1 \/var\/www\/html\/owncloud\/apps\/files_external\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Net\/SSH2.php(1462): phpseclib3\\Net\\SSH2->get_binary_packet()\n#2 \/var\/www\/html\/owncloud\/apps\/files_external\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Net\/SSH2.php(1338): phpseclib3\\Net\\SSH2->key_exchange()\n#3 \/var\/www\/html\/owncloud\/apps\/files_external\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Net\/SSH2.php(2090): phpseclib3\\Net\\SSH2->connect()\n#4 \/var\/www\/html\/owncloud\/apps\/files_external\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Net\/SSH2.php(2068): phpseclib3\\Net\\SSH2->sublogin(*** sensitive parameters replaced ***)\n#5 \/var\/www\/html\/owncloud\/apps\/files_external\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Net\/SFTP.php(441): phpseclib3\\Net\\SSH2->login(*** sensitive parameters replaced ***)\n#6 \/var\/www\/html\/owncloud\/apps\/files_external\/lib\/Lib\/Storage\/SFTP.php(140): phpseclib3\\Net\\SFTP->login(*** sensitive parameters replaced ***)\n#7 \/var\/www\/html\/owncloud\/apps\/files_external\/lib\/Lib\/Storage\/SFTP.php(156): OCA\\Files_External\\Lib\\Storage\\SFTP->getConnection()\n#8 \/var\/www\/html\/owncloud\/lib\/private\/Files\/External\/LegacyUtil.php(207): OCA\\Files_External\\Lib\\Storage\\SFTP->test(false, true)\n#9 \/var\/www\/html\/owncloud\/apps\/files_external\/lib\/Controller\/StoragesController.php(254): OC\\Files\\External\\LegacyUtil::getBackendStatus('\\\\OCA\\\\Files_Exte...', Array, false, true)\n#10 \/var\/www\/html\/owncloud\/apps\/files_external\/lib\/Controller\/StoragesController.php(303): OCA\\Files_External\\Controller\\StoragesController->updateStorageStatus(Object(OC\\Files\\External\\StorageConfig), true)\n#11 \/var\/www\/html\/owncloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php(153): OCA\\Files_External\\Controller\\StoragesController->show(3, true)\n#12 \/var\/www\/html\/owncloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php(85): OC\\AppFramework\\Http\\Dispatcher->executeController(Object(OCA\\Files_External\\Controller\\GlobalStoragesController), 'show')\n#13 \/var\/www\/html\/owncloud\/lib\/private\/AppFramework\/App.php(100): OC\\AppFramework\\Http\\Dispatcher->dispatch(Object(OCA\\Files_External\\Controller\\GlobalStoragesController), 'show')\n#14 \/var\/www\/html\/owncloud\/lib\/private\/AppFramework\/Routing\/RouteActionHandler.php(47): OC\\AppFramework\\App::main('OCA\\\\Files_Exter...', 'show', Object(OC\\AppFramework\\DependencyInjection\\DIContainer), Array)\n#15 \/var\/www\/html\/owncloud\/lib\/private\/Route\/Router.php(341): OC\\AppFramework\\Routing\\RouteActionHandler->__invoke(Array)\n#16 \/var\/www\/html\/owncloud\/lib\/base.php(915): OC\\Route\\Router->match('\/apps\/files_ext...')\n#17 \/var\/www\/html\/owncloud\/index.php(54): OC::handleRequest()\n#18 {main}","File":"\/var\/www\/html\/owncloud\/apps\/files_external\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Net\/SSH2.php","Line":3440}


Can anyone help me with this

Can anyone have the solution for this?

Beware, this is a hack, no warranties.

As it was working at oC 10.6, I would try to replace the files_external app by the one extracted from oC 10.6 tarball. Doing so, you’ll maybe have to deal with integrity issues afterwards.

Reason: Both oC 10.6 and 10.7 come with the same files_external 0.7.1. But the used library phpseclib obviously differs, or at least the file Net/SSH2.php is different.

Good luck for you, @Gowtham.s.

EDIT: Well, maybe I shouldn’t give such advices to other users, but this is what I would do being in this situation.

1 Like

I think if you read my article and deal with it, you will be able to set up SFTP access again with Ubuntu 18.04 and OC 10.7 secure, without possibly exposing yourself to other problems during the downgrade from SSH2.php or other dirty hacks.

1 Like

@alfredb thank you for your support the replaced files_external 0.7.1 is working now.

2 Likes

Hi, could you please explain how you do it?

Can you describe the issue in detail so that i can able to help you.

I have installed old version of owncloud 10.6 in another server to get the files_external after that i just replaced the files in my updated server 10.7 owncloud.

1 Like

Hi again,
I’m in the same situation. I have both 10.6 and 10.7 installations on different servers.
I’m using Univention VM (ESX) with Owncloud Server installed as docker and I don’t know how to copy one folder from one docker to another.
Hope you can help.

I just found how to properly make copies between dockers.

do you copy all the files_external folder (with 15k files) or specific files or sub-folders?

Thanks

Yes, you should copy (replace) the whole files_external app folder.

Thank you. it works for me too

1 Like

Hey @NMA @Gowtham.s,

i’m not sure but i think using an older version of a file could be a risk / could cause other bugs. Maybe you could try update the configuration of your SSH server as already explained by @4bob in SFTP external storage access not working | RuntimeException: Invalid size - #6 by 4bob ?

Downgrading to the previous (minor) version should be an acceptable risk, at least for me. OTOH, to be forced to upgrade any unrelated 3rd party software (ssh server?) is not acceptable. Nobody knows why ownCloud packs a non-working version into the 10.7 tarball.

Hey,

if i’m understanding the previous posting correctly there is no need to upgrade any 3rd party software. I think the problem could be originating from an insecurely configured SSH server and the new version of this file:

could now deny to connecting to such insecure SSH servers.

But maybe some one could open an issue for the ownCloud developers so that they could investigate this topic in more detail?

Maybe, yes. But such a change shouldn’t be made silently in a minor upgrade, as it breaks the functionality. And it should throw something other than “RuntimeException: Invalid size”. It’s IMHO simply a matter of software quality, period.

Hey,

i don’t think that ownCloud 10.7.0 was a minor upgrade. From what i know ownCloud changed the release model and every 10.x version like 10.5.0 or 10.6.0 is a major release (only 10.5.0 to 10.5.1 would be a minor upgrade).

And from what i know library upgrades can always happen on major upgrades, and the upgrade from phpseclib/phpseclib 2.0.29 to 3.0.6 (which seems to be also a major change) is mentioned in the ownCloud changelog of 10.7.

But i might be also completely wrong so apologize if i’m getting something wrong. :cry:

Hey,

i also did some short research and found:

I think it could be possible that this problem is caused by a bug introduced in the major release 3.0.3 of this phpseclib 3rdparty library (included in ownCloud 10.7.0) which was fixed in version 3.0.10 of phpseclib which seems to be included in the next upcoming release of ownCloud: