News for hackers. Stuff that matters.
Re:Python typosquatting is about more than typos by throw_m239339 on Friday October 02, 2020 @03:46PM (#24666382)
I like the go way: import a url. If you want to alias the namespace however you want afterward then that's your problem. It doesn't solve every single security issues, obviously. But at the very least the source of the code is more transparent.

Second option: signed packages. A warning when a package is not digitally signed.

Finally, a package repository curated by whatever language foundation. But then we are getting close to OS wide native package management...

But at the very least namespace+package name should be the norm for every single package manager out there. instead of just a package name.

So it should be "pip install code.launchpad.net/beautifulsoup", not just "pip install beautifulsoup4", if it's not possible already. And then

    import "code.launchpad.net/beautifulsoup" as beautifulsoup
in the code.
Re:Python typosquatting is about more than typos by btashton on Friday October 02, 2020 @04:35PM (#24666758)
Right URLs never change. Remember when one of the most popular golang logging libraries renamed from github.com/Sirupsen/logrus to github.com/sirupsen/logrus and all of a sudden everything would break because you were using both via some dep vendor.

Or Java where you get 80 char of namespaces that may or may not change because the library moved to be an eclipse project.

Re:Python typosquatting is about more than typos by earthboundkid on Friday October 02, 2020 @11:21PM (#24669243)
FWIW, Go’s module system (which was invented afterwards) explicitly encodes uppercase vs lowercase in a platform independent way internally to prevent that from happening again.
Re:Python typosquatting is about more than typos by Terr_ on Friday October 02, 2020 @05:36PM (#24667259)
> import a url

Or at least have a strong convention that all project namespaces be url-like. That's what Java did decades ago, and it remains one of the ecosystems which care the most about traceability.

Sure, the actual url may drift from the namespace, but at least you've got a much more google-able starting point than "lxml" or whatever.

Re:Python typosquatting is about more than typos by X6S1x6Okd1st on Friday October 02, 2020 @04:03PM (#24666513)
> Second option: signed packages. A warning when a package is not digitally signed.

It's trivial to sign a malicious package with a signature.

The problem is to check and make sure it's signed with the signature

Re:Python typosquatting is about more than typos by Spivak on Friday October 02, 2020 @05:30PM (#24667209)
And it doesn't help typosquatting since baeutifulsoup will have a perfectly valid signature.
Re:Python typosquatting is about more than typos by junon on Saturday October 03, 2020 @03:41AM (#24670332)
Absolutely not. URL-based imports are a security risk, availability nightmare, and fragile system built with the assumption that things are never renamed, taken down or significantly changed, or that the developer always has an internet connection.

Depends cannot be resolved offline, and time becomes a factor for the correctness of code (i.e. you fetch a dependency, code against it, dependency changes public API, coworker fetches your code, fetches the dependency, build is now inexplicably broken).

Not to mention DNS hijacking, BGP, caching, locality, etc. can all affect how dependencies are fetched. Further, not using a registry makes in-house mirrors a nightmare due to having to re-route DNS requests all the time.

It's an all around _terrible_ feature in my opinion and I am very careful to distance myself from any project claiming otherwise.

Re:Python typosquatting is about more than typos by TheDong on Friday October 02, 2020 @04:05PM (#24666533)
Sure, the go way:

    import (
     "fmt"
     "github.com/dimuska139/go-email-normalizer"
    )
    
    func main() {
     fmt.Println(emailnormalizer.NewNormalizer().Normalize("[email protected]"))
    }
Wait, how did I know to do "emailnormalizer.NewNormalizer()"? Well, that's the package name of the package at that url.

The package name is only the same as the last part of the URL in go by convention, and importing a package can put an arbitrary package identifier into your package scope.

Re:Python typosquatting is about more than typos by LukeShu on Friday October 02, 2020 @04:09PM (#24666560)
FWIW, `goimports` would say "OK, technically that's valid, but I'm going to complain unless you explicitly import it as 'emailnormalizer'".

    import (
            "fmt"

            emailnormalizer "github.com/dimuska139/go-email-normalizer"
    )
Re:Python typosquatting is about more than typos by earthboundkid on Friday October 02, 2020 @11:30PM (#24669285)
Re:Python typosquatting is about more than typos by watt on Saturday October 03, 2020 @04:58AM (#24670625)
and what happened to the "go-" prefix? is it silently dropped?
Re:Python typosquatting is about more than typos by sheenobu on Saturday October 03, 2020 @07:03AM (#24671173)
No. The go files just have "package emailnormalizer" within the go files, so that is the name that you use to reference it, even if the import url is different.
Re:Python typosquatting is about more than typos by user5994461 on Friday October 02, 2020 @04:13PM (#24666589)
Plot twist: the go way works in python.

You can pip install from a github URL, preferably with a branch rather than master.

Re:Python typosquatting is about more than typos by runarberg on Friday October 02, 2020 @04:10PM (#24666569)
Will URL imports actually solve the problem. Couldn’t a malicious actor simply register a similar name: e.g. `pip install code.lauchpad.net/beautifulsoup`?

I would also guess many packages would be hosted on github: `pip install popular-org.github.io/package` which could be typo-squatted by creating a similar sounding github user `pip install poplar-org.github.io/package`.

Re:Python typosquatting is about more than typos by TylerE on Friday October 02, 2020 @04:57PM (#24666957)
Or for that matter what happens if the original author loses control of the domain?
Re:Python typosquatting is about more than typos by earthboundkid on Friday October 02, 2020 @11:32PM (#24669294)
If you lose the domain, the old packages can’t be changed because they have a hash. New, evil packages are a problem, but that can also happen now if someone steals your password or does an email reset of your account.