MEGAcmd icon indicating copy to clipboard operation
MEGAcmd copied to clipboard

Logging in with wrong password causes an infinite loop on the mega-cmd-server

Open picaronin opened this issue 11 months ago • 3 comments

MEGAcmd version

1.7.0

Operating System/Platform

Linux

Platform version. In the case of Linux, please enter the Linux distribution you are using.

Debian 12

Steps

Logging in with an incorrect password, both in interactive and no-interactive mode.

MEGACMD> login [email protected] "WRONG_PASSWORD"

or

mega-login [email protected] "WRONG_PASSWORD"

Expected behavior

Server response with access denied.

Actual behavior

The mega-cmd-server enters an infinite loop without giving any response to the login command. The Debian server freezes waiting for a response that never comes.

Attached is the mega-cmd-server --debug-full log with the responses it generates.


[API:debug: 00:58:33] cs Retrying the last request after code: 6 [API:debug: 00:58:33] Req command counts: us:1 [API:debug: 00:58:33] cs POST target URL: https://g.api.mega.co.nz/cs?id=ejvkpyaolc&ak=BdARkQSQ&v=2 [API:debug: 00:58:33] cs Sending 154: [{"a":"us","user":"[email protected]","uh":"prtRKvNkMInmqYJAw_j1uA","sek":"LQ5Cce04sEeZuCK_vHek2g","si":"ebQUSwWnv2Qj2aLyioXYngjiH2EpP4NTbA_nZrqkiYc"}] (at ds: 51088) [API:debug: 00:58:33] Adding curl socket 74 to 2 [API:debug: 00:58:34] Removing socket 74 [API:debug: 00:58:34] cs CURLMSG_DONE with error 22: HTTP response code said error [API:debug: 00:58:34] cs CURLMSG_DONE with HTTP status: 402 from g.api.mega.co.nz - 66.203.125.13 [API:debug: 00:58:34] cs Received 0: (at ds: 51089) [API:warn: 00:58:34] cs REQ_FAILURE. Status: 402 CURLcode: 22 Content-Length: -1 buffer? 0 bufferSize: 0 [API:warn: 00:58:34] Retrying cs request in 40 ds [API:debug: 00:58:38] cs Retrying the last request after code: 6 [API:debug: 00:58:38] Req command counts: us:1 [API:debug: 00:58:38] cs POST target URL: https://g.api.mega.co.nz/cs?id=ejvkpyaolc&ak=BdARkQSQ&v=2 [API:debug: 00:58:38] cs Sending 154: [{"a":"us","user":"[email protected]","uh":"prtRKvNkMInmqYJAw_j1uA","sek":"LQ5Cce04sEeZuCK_vHek2g","si":"ebQUSwWnv2Qj2aLyioXYngjiH2EpP4NTbA_nZrqkiYc"}] (at ds: 51129) [API:debug: 00:58:38] Adding curl socket 74 to 2 [API:debug: 00:58:38] Removing socket 74 [API:debug: 00:58:38] cs CURLMSG_DONE with error 22: HTTP response code said error [API:debug: 00:58:38] cs CURLMSG_DONE with HTTP status: 402 from g.api.mega.co.nz - 66.203.125.13 [API:debug: 00:58:38] cs Received 0: (at ds: 51133) [API:warn: 00:58:38] cs REQ_FAILURE. Status: 402 CURLcode: 22 Content-Length: -1 buffer? 0 bufferSize: 0 [API:warn: 00:58:38] Retrying cs request in 74 ds [API:debug: 00:58:45] cs Retrying the last request after code: 6 [API:debug: 00:58:45] Req command counts: us:1 [API:debug: 00:58:45] cs POST target URL: https://g.api.mega.co.nz/cs?id=ejvkpyaolc&ak=BdARkQSQ&v=2 [API:debug: 00:58:45] cs Sending 154: [{"a":"us","user":"[email protected]","uh":"prtRKvNkMInmqYJAw_j1uA","sek":"LQ5Cce04sEeZuCK_vHek2g","si":"ebQUSwWnv2Qj2aLyioXYngjiH2EpP4NTbA_nZrqkiYc"}] (at ds: 51207) [API:debug: 00:58:45] Adding curl socket 74 to 2 [API:debug: 00:58:45] Removing socket 74 [API:debug: 00:58:45] cs CURLMSG_DONE with error 22: HTTP response code said error [API:debug: 00:58:45] cs CURLMSG_DONE with HTTP status: 402 from g.api.mega.co.nz - 66.203.125.13 [API:debug: 00:58:45] cs Received 0: (at ds: 51208) [API:warn: 00:58:45] cs REQ_FAILURE. Status: 402 CURLcode: 22 Content-Length: -1 buffer? 0 bufferSize: 0 [API:warn: 00:58:45] Retrying cs request in 169 ds .....

picaronin avatar Jan 22 '25 19:01 picaronin

I can confirm the bug... did a typo on the login email (not the password) but didn't notice so I kept retrying and the server kept freezing... later in debug I noticed the same thing as posted by OP, it keeps looping on 402 http error code.

ViperCode7 avatar Jan 28 '25 22:01 ViperCode7

There will soon be a release that addresses this. In the meantime, you can cancel the login by opening a new MEGAcmdShell and simply:

logout

polmr avatar Jan 29 '25 06:01 polmr

I am currently saving the situation by limiting the execution time and subsequently handling the script's response.

timeout --signal=HUP 5s mega-login USER "PASSWORD"

picaronin avatar Jan 29 '25 10:01 picaronin