Installation hint crashes when user names contain at sign

  • Done
  • quality assurance status badge
Details
3 participants
  • Ludovic Courtès
  • Ludovic Courtès
  • Csepp
Owner
unassigned
Submitted by
Ludovic Courtès
Severity
normal
L
L
Ludovic Courtès wrote on 31 Jan 2023 18:05
(address . bug-guix@gnu.org)
87edratz17.fsf@inria.fr
A funny thing was reported earlier today on the Café Guix channel:

Toggle snippet (35 lines)
$ guix install hello [17:52]
building profile with 5 packages...
hint: Backtrace:
17 (primitive-load "/usr/local/bin/guix")
In guix/ui.scm:
2279:7 16 (run-guix . )
2242:10 15 (run-guix-command _ . )
In ice-9/boot-9.scm:
1752:10 14 (with-exception-handler _ _ #:unwind? _ # )
In guix/status.scm:
835:3 13 ()
815:4 12 (call-with-status-report _ )
In guix/store.scm:
1300:8 11 (call-with-build-handler _ )
1300:8 10 (call-with-build-handler # ?)
In guix/build/syscalls.scm:
1440:3 9 ()
1407:4 8 (call-with-file-lock/no-wait _ _ )
In guix/scripts/package.scm:
325:7 7 (build-and-use-profile _ "/var/guix/profiles/per-user/?" ?)
In guix/ui.scm:
312:5 6 (display-hint _ )
1451:24 5 (texi->plain-text )
In texinfo.scm:
1132:22 4 (parse )
980:31 3 (loop #<input: string 2b6e5926be70> (fragment) _ _ )
967:36 2 (loop #<input: string 2b6e5926be70> #f # ?)
92:2 1 (command-spec )
In ice-9/boot-9.scm:
1685:16 0 (raise-exception _ #:continuable? )
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Throw to key #E1E1E1">parser-error' with args(#f "Unknown command" univ)'.

This is because the user name ends in “@univ…”, which ‘display-hint’
interprets as Texinfo.

Ludo’.
L
L
Ludovic Courtès wrote on 24 Feb 2023 11:28
(address . 61201@debbugs.gnu.org)
87sfev2w8k.fsf@gnu.org
Ludovic Courtès <ludovic.courtes@inria.fr> skribis:

Toggle quote (6 lines)
> A funny thing was reported earlier today on the Café Guix channel:
>
> $ guix install hello [17:52]
> building profile with 5 packages...
> hint: Backtrace:

[...]

Toggle quote (14 lines)
> In guix/ui.scm:
> 312:5 6 (display-hint _ )
> 1451:24 5 (texi->plain-text )
> In texinfo.scm:
> 1132:22 4 (parse )
> 980:31 3 (loop #<input: string 2b6e5926be70> (fragment) _ _ )
> 967:36 2 (loop #<input: string 2b6e5926be70> #f # ?)
> 92:2 1 (command-spec )
> In ice-9/boot-9.scm:
> 1685:16 0 (raise-exception _ #:continuable? )
>
> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> Throw to key #E1E1E1">parser-error' with args(#f "Unknown command" univ)'.

Here’s one way to reproduce the bug, showing a crash in ‘display-hint’
due to an unescaped brace:

Toggle snippet (31 lines)
$ mkdir /tmp/x{ample
$ touch /tmp/x{ample/guix.scm
$ (cd '/tmp/x{ample' ; guix shell)
guix shell: error: not loading '/tmp/x{ample/guix.scm' because not authorized to do so
hint: Backtrace:
13 (primitive-load "/home/ludo/.config/guix/current/bin/guix")
In guix/ui.scm:
2279:7 12 (run-guix . _)
2242:10 11 (run-guix-command _ . _)
In ice-9/boot-9.scm:
1752:10 10 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _)
In guix/scripts/shell.scm:
308:15 9 (_)
In guix/ui.scm:
312:5 8 (display-hint _ _)
1451:24 7 (texi->plain-text _)
In texinfo.scm:
1132:22 6 (parse _)
980:31 5 (loop #<input: string 7feb8b300d20> (*fragment*) _ _ _)
980:31 4 (loop #<input: string 7feb8b300d20> #f _ _ _)
911:31 3 (loop #<input: string 7feb8b300d20> #f #<procedure identity (x)> #f _)
746:27 2 (_ #<input: string 7feb8b300d20> #f (example smallexample verbatim lisp smalllisp menu w %) #<procedure 7feb9aea1948 at texin…> …)
In sxml/ssax/input-parse.scm:
88:2 1 (next-token _ _ _ _)
In ice-9/boot-9.scm:
1685:16 0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Throw to key `parser-error' with args `(#<input: string 7feb8b300d20> "EOF while reading a token " "reading char data")'.

Ludo’.
C
(name . Ludovic Courtès)(address . ludo@gnu.org)
87h6vbjomm.fsf@riseup.net
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (59 lines)
> Ludovic Courtès <ludovic.courtes@inria.fr> skribis:
>
>> A funny thing was reported earlier today on the Café Guix channel:
>>
>> $ guix install hello [17:52]
>> building profile with 5 packages...
>> hint: Backtrace:
>
> [...]
>
>> In guix/ui.scm:
>> 312:5 6 (display-hint _ )
>> 1451:24 5 (texi->plain-text )
>> In texinfo.scm:
>> 1132:22 4 (parse )
>> 980:31 3 (loop #<input: string 2b6e5926be70> (fragment) _ _ )
>> 967:36 2 (loop #<input: string 2b6e5926be70> #f # ?)
>> 92:2 1 (command-spec )
>> In ice-9/boot-9.scm:
>> 1685:16 0 (raise-exception _ #:continuable? )
>>
>> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
>> Throw to key #E1E1E1">parser-error' with args(#f "Unknown command" univ)'.
>
> Here’s one way to reproduce the bug, showing a crash in ‘display-hint’
> due to an unescaped brace:
>
> $ mkdir /tmp/x{ample
> $ touch /tmp/x{ample/guix.scm
> $ (cd '/tmp/x{ample' ; guix shell)
> guix shell: error: not loading '/tmp/x{ample/guix.scm' because not authorized to do so
> hint: Backtrace:
> 13 (primitive-load "/home/ludo/.config/guix/current/bin/guix")
> In guix/ui.scm:
> 2279:7 12 (run-guix . _)
> 2242:10 11 (run-guix-command _ . _)
> In ice-9/boot-9.scm:
> 1752:10 10 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _)
> In guix/scripts/shell.scm:
> 308:15 9 (_)
> In guix/ui.scm:
> 312:5 8 (display-hint _ _)
> 1451:24 7 (texi->plain-text _)
> In texinfo.scm:
> 1132:22 6 (parse _)
> 980:31 5 (loop #<input: string 7feb8b300d20> (*fragment*) _ _ _)
> 980:31 4 (loop #<input: string 7feb8b300d20> #f _ _ _)
> 911:31 3 (loop #<input: string 7feb8b300d20> #f #<procedure identity (x)> #f _)
> 746:27 2 (_ #<input: string 7feb8b300d20> #f (example smallexample verbatim lisp smalllisp menu w %) #<procedure 7feb9aea1948 at texin…> …)
> In sxml/ssax/input-parse.scm:
> 88:2 1 (next-token _ _ _ _)
> In ice-9/boot-9.scm:
> 1685:16 0 (raise-exception _ #:continuable? _)
>
> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> Throw to key `parser-error' with args `(#<input: string 7feb8b300d20> "EOF while reading a token " "reading char data")'.
>
> Ludo’.

Would it be heresy to recommend that plain strings and strings that
contain texinfo markup be separate types to catch this sort of thing?
In 2023 it's pretty embarrassing to have bugs that are basically SQL
injections.
L
L
Ludovic Courtès wrote on 27 Feb 2023 23:55
Re: bug#61749: [PATCH] ui: 'display-hint' quotes extra arguments for Texinfo.
(address . 61749-done@debbugs.gnu.org)(address . 61201-done@debbugs.gnu.org)
877cw2g1m3.fsf_-_@gnu.org
Ludovic Courtès <ludo@gnu.org> skribis:

Toggle quote (30 lines)
>
> Previously, common practice was to splice arbitrary strings (user names,
> file names, etc.) into Texinfo snippets passed to 'display-hint'. This
> is unsafe in the general case because at signs and braces need to be
> escaped to produced valid Texinfo. This commit addresses that.
>
> * guix/ui.scm (texinfo-quote): New procedure.
> (display-hint): When ARGUMENTS is non-empty, pass it to 'texinfo-quote'
> and call 'format'.
> (report-unbound-variable-error, check-module-matches-file)
> (display-collision-resolution-hint, run-guix-command): Remove explicit
> 'format' call; pass 'format' arguments as extra arguments to 'display-hint'.
> * gnu/services/monitoring.scm (zabbix-front-end-config): Likewise.
> * guix/scripts.scm (warn-about-disk-space): Likewise.
> * guix/scripts/build.scm (%standard-cross-build-options)
> (%standard-native-build-options): Likewise.
> * guix/scripts/describe.scm (display-checkout-info): Likewise.
> * guix/scripts/environment.scm (suggest-command-name): Likewise.
> * guix/scripts/home.scm (process-command): Likewise.
> * guix/scripts/home/edit.scm (service-type-not-found): Likewise.
> * guix/scripts/import.scm (guix-import): Likewise.
> * guix/scripts/package.scm (display-search-path-hint): Likewise.
> * guix/scripts/pull.scm (build-and-install): Likewise.
> * guix/scripts/shell.scm (auto-detect-manifest): Likewise.
> * guix/scripts/system.scm (check-file-system-availability): Likewise.
> (guix-system): Likewise.
> * guix/scripts/system/edit.scm (service-type-not-found): Likewise.
> * guix/status.scm (print-build-event): Likewise.

Pushed as 43c36c5c9f7a31649eb059fd16ed82bde20da3fc.

Ludo’.
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 61201@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 61201
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch