OK, I did found just one thing… but since it requires a lot of situational variables to line up (and is therefore unlikely to happen in practice), I think I can share it publically.
If you run a script with a user that has high permissions (e.g. “admin”), and within that script you write a file that you then import from that same script (e.g. a file that you’ve fetched via “/tool fetch”)… Even in normal circumstances, you need to do a “:delay” of at least two seconds for the file to be written on disk before importing it.
Within that delay, an API user that only has “write,api,ftp” policy can modify the file to anything it wants, including, for example “/export file=FileWithPasswordsAndAll.txt” or “/user set limitedApiUser group=full”, and the script would execute just that, allowing the user to access previously restricted data and functionality.
This does not work if the user does not have “ftp” permissions, since even the API needs these to read/write files from the “/file” menu. Also, the writing needs to happen EXACTLY during the delay. If it’s too early, the script will override the malicious content with its own, and if it’s too late, the script would already be executing the actual script, rather than the malicious one.
Also, who gives anyone write access to their router via the API protocol without trusting them? Therefore, even if there’s a breach via this method, it will need to happen by an insider - someone with a RouterOS user account with sufficient permissions.
The above is in v6.12. I tried a lot of other things, but failed to escalate my permissions. I don’t know if earlier versions are vulnerable to the other things I’ve tried, including:
- Having an “admin” script execute another “admin” script, except that the second “admin” script has been altered by the limited user during the execution of the first admin script, before it got around to running the second one.
- Having a limited user “add” a script with “policy” that exceeds its granted ones.
- Simply running an “admin” owned script with full permissions from a user with limited permissions… The fact that this one fails is kind of a bummer though… I would’ve thought that if the script is owned by “admin” AND has lots of permissions granted on it, those would be temporarily granted when the script is run by anyone. Instead, these reflect minimum permissions a calling user needs, PLUS the script restricting itself to the specified permissions if additional ones are granted.
@rextended I’m guessing that’s not the one you have in mind… Have you tried duplicating your issue with 6.12 yet?