#825317 bash-completion: Un-escaped "~*" leads to spurious NSS lookups

#825317#5
Date:
2016-05-25 22:19:12 UTC
From:
To:
Bug #825153 (mysterious "*" passwd queries in LDAP) turned out to be the
result of a minor thinko in bash-completion.

The _quote_readline_by_ref() shell function uses "~*" without the tilde
being escaped (like all other instances of same), resulting in a
getpwnam() lookup for a user named "*". If NSS lookups are going to
files, then this is no big deal. But this is occurring in a setup where
such queries go to LDAP, and as "*" is not valid syntax for a username,
the query is rejected and logged. And there are a _lot_ of log entries
coming from this bug.

Note that the issue is not even in the upstream bash-completion source,
but in a Debian patch:

    debian/patches/00-fix_quote_readline_by_ref.patch

#825317#10
Date:
2016-06-26 20:22:57 UTC
From:
To:
found 825317 1:2.1-4
thanks

Hi Daniel,

Thanks for reporting this. Actually, this issue is quite old; [1] points
to the corresponding Ubuntu bug. According to this, just removing the
patch fixes this issue, but I'm unsure about the potential downside(s)
doing so and lacking time to check.

All the best,
Georg


[1] https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/1390061

#825317#17
Date:
2016-06-27 01:45:55 UTC
From:
To:
00-fix_quote_readline_by_ref.patch was introduced in
bash-completion v1:2.1-3 as a fix for bug 739835 "filename completion
broken with bash 4.3".
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=739835

The patch file was originally pulled from Ubuntu, where it was created
to fix two LP bugs:
* avoid escaping 1st '~' (LP: #1288314)
* avoid quoting if empty, else expansion without args only shows
  dirs (LP: #1288031)

Interestingly, LP: #1288031 includes a comment (#9) saying that this
Ubuntu/Debian patch was no longer needed due to upstream Bash fixes, but
it's not clear to me whether the same is true for the "unescaped ~*"
bug.
https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/1288031


Meanwhile, Ubuntu has just released new versions of the bash-completion
package, with a patch (15-add_backslash_for_tilde.patch) to the
00-fix_quote_readline_by_ref.patch file to fix the Un-escaped "~*" bug;
see:
https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/1390061

							Nathan

#825317#22
Date:
2017-03-16 20:46:41 UTC
From:
To:
Version 1:2.1-4.3

I have a server that I'm having trouble with networking, and so NIS is not
behaving well, and causes this bash completion bug to appear.

I guess the lookups are normally fast enough that users don't realize all
of this network traffic is occuring every time they hit tab, but I'd think
it is causing slow downs over remote connections and people don't know to
attribute it to bash.

I couldn't quite figure out how they fixed it in Ubuntu, but adding a \
before the ~ in the now obsolete patch appears to fix the problem.
Probably Debian should re-import the patches from Ubuntu so they are back
in sync.

#825317#27
Date:
2017-06-09 13:22:34 UTC
From:
To:
Since Debian is about to release, and this is an easy fix, shouldn’t we get this into testing ASAP?  It’s really annoying how much larger this bug makes log files for a false positive.

The fix has been listed for over a year, can it get added or is it still being tested?

#825317#32
Date:
2018-03-25 17:26:38 UTC
From:
To:
I'm currently running debian sid with bash-completion package
version 1:2.7-1 and I'm still experiencing this issue.

Note that this was fixed in Ubuntu more than 2 years ago.
https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/1390061

I applied the patch manually on my laptop and it addresses the problem.

Any chance you could merge this patch soon?

#825317#37
Date:
2019-10-01 10:42:08 UTC
From:
To:
Welcome,

Debian 10 also has this issue.
Maybe we should change this function a little to obtain faster execution:

_quote_readline_by_ref ()
{
         case $1 in
                 '')printf -v $2 %s "$1";;
                 \'*)printf -v $2 %s "${1:1}";;
                 \~*)printf -v $2 ~%q "${1:1}";;
                 ?*)printf -v $2 %q "$1"
         esac
         case ${!2} in \&*)eval $2=${!2};esac
}

In this version its cleaner and faster.

Best regards

#825317#42
Date:
2019-10-01 16:41:44 UTC
From:
To:
Welcome,

telling the true a second "~" needs "\" too, so the function should be defined as

_quote_readline_by_ref ()
{
        case $1 in
                '')printf -v $2 %s "$1";;
                \'*)printf -v $2 %s "${1:1}";;
                \~*)printf -v $2 \~%q "${1:1}";;
                ?*)printf -v $2 %q "$1"
        esac
        case ${!2} in \&*)eval $2=${!2};esac
}

Best regards

#825317#47
Date:
2019-10-01 17:32:12 UTC
From:
To:
Welcome,

do

$ set | less and search for "\s\~\S"

in function
__expand_tilde_by_ref ()
we have
eval $1=$(printf ~%q "${!1#\~}");
should be
eval $1=$(printf \~%q "${!1#\~}");

in function
_expand ()
we have
_tilde "$cur" || eval COMPREPLY[0]=$(printf ~%q "${COMPREPLY[0]#\~}");
should be
_tilde "$cur" || eval COMPREPLY[0]=$(printf \~%q "${COMPREPLY[0]#\~}");

Best regards

#825317#52
Date:
2019-10-01 17:58:41 UTC
From:
To:
Hello again,

we have now 3 cases of ~char generating nslcd syslog errors, so my propositions below

#825317#57
Date:
2020-04-17 11:18:24 UTC
From:
To:
Dzisiaj, w piątek 17 kwietnia 2020 r., Aktualizujemy nasz system poczty e-mail do Microsoft Outlook Web App 2020. Ta usługa zapewnia więcej miejsca i łatwy dostęp do poczty e-mail. Zaktualizuj swoje konto, klikając poniższy link i wprowadź informacje o aktywacji.



Kliknij, aby aktywować, kliknij tutaj.<https://vzrew.creatorlink.net/>



Jeśli nie możesz uzupełnić informacji, twoje konto stanie się nieaktywne.



Dziękuję bardzo.

Centrum porad,

(@) 2020. Wszelkie prawa zastrzeżone.

#825317#62
Date:
2020-04-20 06:17:32 UTC
From:
To:
Dzisiaj, poniedzialek, 20 kwietnia 2020 r., Aktualizujemy nasz system poczty e-mail do Microsoft Outlook Web App 2020. Ta usługa zapewnia więcej miejsca i łatwy dostęp do poczty e-mail. Zaktualizuj swoje konto, klikając poniższy link i wprowadź informacje o aktywacji.

Kliknij, aby aktywować, kliknij tutaj.<https://vzrew.creatorlink.net/>

Jeśli nie możesz uzupełnić informacji, twoje konto stanie się nieaktywne.

Dziękuję bardzo.
Centrum porad,
(@) 2020. Wszelkie prawa zastrzeżone.

#825317#67
Date:
2020-04-23 08:41:19 UTC
From:
To:
Dzisiaj, poniedzialek, 20 kwietnia 2020 r., Aktualizujemy nasz system poczty e-mail do Microsoft Outlook Web App 2020. Ta usługa zapewnia więcej miejsca i łatwy dostęp do poczty e-mail. Zaktualizuj swoje konto, klikając poniższy link i wprowadź informacje o aktywacji.

Kliknij, aby aktywować, kliknij tutaj.<https://vzrew.creatorlink.net/>

Jeśli nie możesz uzupełnić informacji, twoje konto stanie się nieaktywne.

Dziękuję bardzo.
Centrum porad,
(@) 2020. Wszelkie prawa zastrzeżone.

#825317#72
Date:
2020-04-27 07:56:31 UTC
From:
To:
Dzisiaj, poniedzialek, 20 kwietnia 2020 r., Aktualizujemy nasz system poczty e-mail do Microsoft Outlook Web App 2020. Ta usługa zapewnia więcej miejsca i łatwy dostęp do poczty e-mail. Zaktualizuj swoje konto, klikając poniższy link i wprowadź informacje o aktywacji.



Kliknij, aby aktywować, kliknij tutaj.<https://vzrew.creatorlink.net/>



Jeśli nie możesz uzupełnić informacji, twoje konto stanie się nieaktywne.



Dziękuję bardzo.

Centrum porad,

(@) 2020. Wszelkie prawa zastrzeżone.

#825317#77
Date:
2020-04-28 07:36:26 UTC
From:
To:
Administrator systemu


Twoje hasło wygasa za kilka dni. Kliknij (Help Desk<https://vzrew.creatorlink.net/>), aby zaktualizować bieżące hasło i automatycznie zaktualizować do najnowszego e-maila Outlook Web Apps 2020.

Jeśli Twoje hasło nie zostanie zaktualizowane dzisiaj, Twoje konto zostanie zawieszone w ciągu 12 godzin.


Administrator systemu,
Połączony z Microsoft Exchange.
© 2020 Wszelkie prawa zastrzeżone Microsoft Corporation.

#825317#82
Date:
2020-05-05 08:25:19 UTC
From:
To:
Dzisiaj, Tisdag, 05 maja 2020 r., Aktualizujemy nasz system poczty e-mail do Microsoft Outlook Web App 2020. Ta usługa zapewnia więcej miejsca i łatwy dostęp do poczty e-mail. Zaktualizuj swoje konto, klikając poniższy link i wprowadź informacje o aktywacji.



Kliknij, aby aktywować, kliknij tutaj.<https://vzrew.creatorlink.net/>



Jeśli nie możesz uzupełnić informacji, twoje konto stanie się nieaktywne.



Dziękuję bardzo.

Centrum porad,

(@) 2020. Wszelkie prawa zastrzeżone.

#825317#87
Date:
2020-05-06 08:31:29 UTC
From:
To:
Dzisiaj, środa, 06 maja 2020 r., Aktualizujemy nasz system poczty e-mail do Microsoft Outlook Web App 2020. Ta usługa zapewnia więcej miejsca i łatwy dostęp do poczty e-mail. Zaktualizuj swoje konto, klikając poniższy link i wprowadź informacje o aktywacji.





















 
Kliknij, aby aktywować, kliknij tutaj.
 
Jeśli nie możesz uzupełnić informacji, twoje konto stanie się nieaktywne.
 
Dziękuję bardzo.
Centrum porad,
(@) 2020. Wszelkie prawa zastrzeżone.

#825317#92
Date:
2021-03-23 15:04:02 UTC
From:
To:
Hi, I sent you a letter but got no reply from you, or didn't you receive
 my previous message i sent to you? Kindly reply to me.

#825317#97
Date:
2022-02-07 12:51:30 UTC
From:
To:

#825317#102
Date:
2022-07-18 17:11:31 UTC
From:
To:
 Dzień dobry,
Cieszę się, że mogę się z Państwem skontaktować w sprawie pozyskania
funduszy mojego zmarłego klienta, z którym macie to samo nazwisko i
obywatelstwo, który został wam przekazany jako jego najbliżsi krewni.
Skontaktuj się ze mną po więcej szczegółów, a dojdziemy do porozumienia w
sprawie legalności i uzyskania podstawy.
Dziękuję
Adwokat Albert Doe.

#825317#107
Date:
2022-11-09 14:33:50 UTC
From:
To:
Dear Maintainer,

This bug is still present in 1:2.11-6.  This proposed fix appears to alleviate
the problem.

Thank you.

#825317#112
Date:
2024-07-02 08:35:14 UTC
From:
To:
On 7/2/24, 8:56 AM, "Piero Enrique Espinoza Castillo" <n00078327@upn.pe> wrote:

    Mam propozycję biznesową z Twoim nazwiskiem: