2023-04-05 23:37:21 +00:00
|
|
|
touch $(echo -e "\e[31mfoo\e[0m")
|
|
|
|
git-annex add
|
2023-04-07 17:13:16 +00:00
|
|
|
git-annex whereis
|
2023-04-05 23:37:21 +00:00
|
|
|
|
|
|
|
That displays "foo" in red twice. Compare with behavior of git commands that
|
|
|
|
display that filename, which display it escaped.
|
|
|
|
|
2023-04-07 17:13:16 +00:00
|
|
|
git-annex should probably do the same, when displaying filenames that it's
|
|
|
|
working on or in messages.
|
|
|
|
|
|
|
|
`git-annex find` is an interesting case because it's expected to be
|
|
|
|
pipeable, and so should have raw filenames. Note that `find` actually
|
|
|
|
escapes such filenames when outputting to a terminal, but not a pipe.
|
|
|
|
|
2023-04-05 23:37:21 +00:00
|
|
|
git porcelain also accepts the escaped form of files as input, necessary for
|
|
|
|
round-tripping though. git-annex currently does not. (git plumbing doesn't
|
|
|
|
either)
|
|
|
|
|
|
|
|
While terminals mostly protect against escape sequences doing very bad
|
|
|
|
things, there are security holes in terminals still being found.
|
|
|
|
|
|
|
|
Of course, such files in git repos can also be exploited by other commands
|
|
|
|
eg `echo *`.
|
|
|
|
|
|
|
|
So this does not seem like a security hole in git-annex, but it would be
|
|
|
|
useful defense in depth against terminal security holes, and also good to
|
|
|
|
behave more like git.
|
|
|
|
|
|
|
|
--[[Joey]]
|
2023-04-07 21:12:55 +00:00
|
|
|
|
|
|
|
> Git.Filename.encode is implemented, and only needs to be used.
|
|
|
|
> Note that core.quotePath controls whether git quotes unicode characters
|
|
|
|
> (by default it does), so once this gets implemented, some users may want
|
|
|
|
> to set that config to false. --[[Joey]]
|
2023-04-08 19:48:32 +00:00
|
|
|
|
2023-04-10 21:03:41 +00:00
|
|
|
> Update: Messages now handles quoting of filenames, and also filtering
|
|
|
|
> out any escape sequences in other things that get displayed (like Keys..)
|
|
|
|
>
|
|
|
|
> Still need to deal with `git-annex find` and `git-annex info $file`
|
|
|
|
> and anything else that outputs without using Messages.
|
|
|
|
> (Eg need to do `git-annex metadata`, `git-annex config --get` and `git-annex schedule` and `git-annex wanted`
|
|
|
|
> and `git-annex required` and `git-annex group`)
|
2023-04-08 19:48:32 +00:00
|
|
|
|
|
|
|
----
|
|
|
|
|
|
|
|
Also:
|
|
|
|
It's possible that keys can also contain an escape sequence, eg in the
|
|
|
|
extension of a SHA-E key. So commands like `git-annex lookupkey`
|
|
|
|
and `git-annex find` that output keys might need to handle
|
|
|
|
that, when outputting to a terminal?
|
|
|
|
|
|
|
|
Also: git-annex initremote with autoenable may be able to cause a remote
|
|
|
|
with a malicious name to be set up?
|
2023-04-10 17:38:14 +00:00
|
|
|
|
|
|
|
Also: Any place that an exception is thrown with an attacker-controlled value.
|
2023-04-10 20:07:54 +00:00
|
|
|
`giveup` has been made to filter out control characters, but that leaves
|
2023-04-10 17:38:14 +00:00
|
|
|
other exceptions, including ones thrown by libraries. Catch all exceptions
|
|
|
|
at top-level (of program and/or worker threads) and filter out control
|
|
|
|
characters?
|