-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
qvm-copy: incorrect error message upon encountering symlink pointing outside copy area #8581
Comments
qrexec-lib from linux-utils v4.2.5 is the last version that successfully sends the broken symlink. I see the exact same error message starting with the next version v4.2.6 of qrexec-lib (up to and including the latest v4.2.14), installed on the receiver side. |
Indeed there is an intentional change to forbid symlinks pointing outside of copying area (it considers both relative symlinks and absolute one - banning the latter completely). |
And yes, the error message needs fixing |
Besides the choice of |
Can this be reconsidered? In fact it says: qvm-copy breaks user's files without warning. It kind of forces users who use symlinks to pack everything to Will Use case: User copies their project/configuration from one VM to another and it is deliberately corrupted by |
@rustybird what is your opinion on coping symlinks? |
qvm-copy/qvm-move is about copying/moving files to another qube in a safe way - so even if the source is malicious, it should still make it hard to trick the user. Having for example a symlink to |
@jamke I wouldn't call it corruption or data loss because * For reference: glibc's list of error strings, musl's. |
@rustybird thank you for noting that copying will be broken with error message, I agree that it is better than to stop working silently, but still worse than simply work as user expects.
All this is obvious and expected by user. How can block device or socket be "copied" or "moved" to other VM? User should not expected it. And hardlinks by design cannot be preserved when copied or moved to another partition/disk. Well known by people who use hardlinks. But misbehaving for symlinks has no obvious reason to be happening. Symlinks are used all other the place by a lot of people, including me. I have a lot of symlinks that target some dirs that are not available most of the time. It is and always was excepted behavior to copy files, dirs and symlinks (both types). Currently I am talking about changes that will break things, that will affect copying process badly, in a way which is NOT expected by user. I will report it as a bug ticket if it exists, even if the ticket will (should?) be closed immediately as
I understand the possible reasons for such validation, but it is not right. You can open FS specification and EXT2/3/4 has only one forbidden char - |
Maybe there can be some flag to make Looks like some alternative for people who actually want to copy symlinks, too. I will simply replace |
You totally can preserve device files or hardlinks with
Generally, inter-VM Filecopy is intended to be rock solid secure. You should be able to have the nastiest source VM send whatever garbage to a good destination VM without that alone compromising the destination. Except that if you don't filter filenames, then just a simple But yes it also would be nice to make that easily configurable. Maybe it could be tri-state: unrestricted filenames / valid UTF-8 only / printable ASCII plus space only
That's a real downside of restrictive Filecopy: Users will fall back on ad-hoc splicing in GNU Anyway, sorry for doing my part to turn this into the Filecopy omni-ticket, when the immediate question is really just "what's a better errno than EILSEQ" |
Technically, it doesn't need to be. It's "file copy error code", which happen to match subset of Linux's errno values. Non-Linux implementation would need to translate (like windows agent does).
Exactly, that's the important question here. Disallowed symlink target should have a different error code than disallowd file name. EXDEV ("Cross-device link") is kinda logical here (normally it's for hardlinks in similar situation, but we'd apply it here to symlinks), but it wouldn't cover the case of symlink target with disallowed characters. Should those have different error code (symlink target pointing outside of dest dir vs symlink target with disallowed characters) ? Technically it may require a bit of refactor, to distinguish between reasons for rejecting symlink target.
@DemiMarie @rustybird any opinion? |
I would expect
Compromising is not done by coping but by software in target qube that is not able to properly work with non-utf8 chars. But symlinks is what user often wants to have properly copied. Isn't it true?
I agree, it would be nice to have options like that. Though I am more worried for broken symlinks. What is the security problem with symlinks in the first place? That users do not understand how they work?
I agree once again, but what should users do if they want something to be copied as it is, binary-perfect? |
@marmarek I still think that rejecting symlinks that point outside the destination area is the right thing to do, because it prevents the following attack:
Nevertheless, the error message is not merely unhelpful but outright misleading, and that is my fault.
|
Yes, I agree here. We may have alternative service (disabled or even not installed by default) that is more permissive, but the default one should be reasonably strict. As for the error - we still need some error code. And then we can make a custom message for it on the client side (as we do for EEXIST for example). |
|
Since Linux errnos are all low numbers, why not use some range at the upper* end of the uint32_t filecopy error code for non-system errors. Without overloading ESOMETHING names at all. For example:
* Edit: Changed UINT32_MAX to INT32_MAX for backwards compatiblity with old senders who would still pass these numbers through to |
Maybe I do not understand the scenario when preventing copying symlinks helps at all.
|
It’s meant as an example of something the user might do by accident.
It’s meant to prevent the user from doing something insecure by accident. That’s why symbolic links that do not point outside of Copying a directory tree with symlinks that point outside of itself across VMs doesn’t make much sense, because such a directory tree is not self-contained: the meaning of these symlinks depends on the contents of other parts of the filesystem.
It depends on what the purpose of the copy is. If I am copying an entire root filesystem, I will use If I am copying a directory tree with scripts, I would replace the absolute symbolic links with relative ones. This is good practice anyway, because it means that the directory tree will mean the same thing on the destination VM as it does on the source VM. |
So, no malicious code is being limited in any way by this change. And if something malicious were running inside the qube, this change would have absolutely zero effect. Preventing user from making possible rare mistake but putting them in a confusion why
And if you need to have absolute symbolic paths? I had such cases many times intentionally. And those symlinks will be breaking Is it possible to add flag at this point to allow copying symlinks "as is", in the way current |
Absolute symlinks make sense only in context of the filesystem they are placed in, if they point outside of the directory you are copying, the target file/dir (usually) won't exists in the target qube. And even if they point inside the directory you are copying, they will (usually) be broken, because the files are placed into a different location than the source. There may be some rare and very specific cases where copying absolute symlinks to another qube make sense, but we won't make default less safe for everybody else just because of that. But having an alternative mechanism that is less strict and disabled by default is a possibility. |
It’s meant as an example of something the user might do by accident.
It’s meant to prevent the user from doing something insecure by accident. That’s why symbolic links that do not point outside of Copying a directory tree with symlinks that point outside of itself across VMs doesn’t make much sense, because such a directory tree is not self-contained: the meaning of these symlinks depends on the contents of other parts of the filesystem.
It depends on what the purpose of the copy is. If I am copying an entire root filesystem, I will use If I am copying a directory tree with scripts, I would replace the absolute symbolic links with relative ones. This is good practice anyway, because it means that the directory tree will mean the same thing on the destination VM as it does on the source VM. |
Consider this use case How should user copy Consider this use case
I really do not think it increases security or safeness. No real case of increasing security except limiting user's actions:
To me it looks more as inability to copy symlinks properly anymore. At least it will affect me exclusively in this way. But OK, I see that you and @DemiMarie look at this in a different way and made up your minds, so, I won't try to convince you any longer.
Yes, ability to copy files @DemiMarie for some reason I see a duplicate reply from you, the same as previous one, not sure it was intentional. |
What is the actual task to be done here? I assume it is not just fixing the error message. @marmarek: would it be possible for you to update this issue to reflect what actually needs to be done, so that I know what to implement? |
This issue is about the error message |
The error message is not great, but at least it is not actively misleading anymore. Will fix QubesOS/qubes-issues#8581 once this is used by qfile-unpacker and qfile-agent.
The error message is not great, but at least it is not actively misleading anymore. Will fix QubesOS/qubes-issues#8581 once this is used by qfile-unpacker and qfile-agent.
The error message is not great, but at least it is not actively misleading anymore. Will fix QubesOS/qubes-issues#8581 once this is used by qfile-unpacker and qfile-agent.
The error message is not great, but at least it is not actively misleading anymore. Will fix QubesOS/qubes-issues#8581 once this is used by qfile-unpacker and qfile-agent.
The error message is not great, but at least it is not actively misleading anymore. Will fix QubesOS/qubes-issues#8581 once this is used by qfile-unpacker and qfile-agent. (cherry picked from commit 34172df)
How to file a helpful issue
Qubes OS release
4.2 rc3
Brief summary
In 4.2 when
qvm-copy
encounters a broken symbolic link it errors out and reports "Invalid or incomplete multibyte or wide character". The true error is that the symlink points to a nonexistent file.(Is it actually even an error though? I suppose it is. The interface to
qvm-copy
appears to be very simple, no flags to tweak the copy semantics, and I assume this is purposeful/philosophical: no tricky corner cases while crossing inter-qube borders, please.)Steps to reproduce
Expected behavior
(a) Copy across the broken symlink
or
(b) Error out and report the broken symlink
Actual behavior
Error out and falsely report an encoding error
The text was updated successfully, but these errors were encountered: