Skip to content

python3Packages.nassl: improve overridden openssl versions#144939

Merged
risicle merged 1 commit intoNixOS:masterfrom
risicle:ris-sslyze-platforms-fix
Nov 9, 2021
Merged

python3Packages.nassl: improve overridden openssl versions#144939
risicle merged 1 commit intoNixOS:masterfrom
risicle:ris-sslyze-platforms-fix

Conversation

@risicle
Copy link
Contributor

@risicle risicle commented Nov 6, 2021

Motivation for this change

ZHF #144627

Firstly override the correct respective base openssl version - this gives us an approximately appropriate set of patches and knownVulnerabilities to start with.

Filter patches that don't apply to the overridden source, fixing the build on darwin.

Add knownVulnerabilities for openssl 1.1.1h.

Would appreciate an aarch64-darwin tester as I think I might have fixed it there too.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

firstly override the correct respective base openssl version - this
gives us an approximately appropriate set of patches and
knownVulnerabilities to start with.

filter patches that don't apply to the overridden source, fixing
the build on darwin.
@github-actions github-actions bot added the 6.topic: python Python is a high-level, general-purpose programming language. label Nov 6, 2021
@ofborg ofborg bot requested a review from veehaitch November 6, 2021 22:40
@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Nov 6, 2021
Copy link
Contributor

@thiagokokada thiagokokada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a change related to fix macOS 🤔 ? Because I remember this package was working for x86_64-linux after this PR #144638.

If yes, wouldn't it be better to limit the openssl changes to macOS?

Edit: forget it, now I understand the changes.

Copy link
Contributor

@thiagokokada thiagokokada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Result of nixpkgs-review pr 144939 run on x86_64-linux 1

5 packages marked as broken and skipped:
  • python38Packages.nassl
  • python38Packages.sslyze
  • python39Packages.nassl
  • python39Packages.sslyze
  • sslyze
nix-build -A python3Packages.nassl
error: Package ‘openssl-1.0.2e’ in /home/thiagoko/Projects/nixpkgs/pkgs/development/libraries/openssl/default.nix:171 is marked as insecure, refusing to evaluate.


       Known issues:
        - Support for OpenSSL 1.0.2 ended with 2019.

       You can install it anyway by allowing this package, using the
       following methods:

       a) To temporarily allow all insecure packages, you can use an environment
          variable for a single invocation of the nix tools:

            $ export NIXPKGS_ALLOW_INSECURE=1

       b) for `nixos-rebuild` you can add ‘openssl-1.0.2e’ to
          `nixpkgs.config.permittedInsecurePackages` in the configuration.nix,
          like so:

            {
              nixpkgs.config.permittedInsecurePackages = [
                "openssl-1.0.2e"
              ];
            }

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
          ‘openssl-1.0.2e’ to `permittedInsecurePackages` in
          ~/.config/nixpkgs/config.nix, like so:

            {
              permittedInsecurePackages = [
                "openssl-1.0.2e"
              ];
            }
(use '--show-trace' to show detailed location information)

@risicle
Copy link
Contributor Author

risicle commented Nov 6, 2021

Yeah :(

nixpkgs-review does obey NIXPKGS_ALLOW_INSECURE=1 to allow you to still review things though (in my experience).

@thiagokokada
Copy link
Contributor

Result of nixpkgs-review pr 144939 run on x86_64-linux 1

4 packages built:
  • python38Packages.nassl
  • python38Packages.sslyze
  • python39Packages.nassl
  • sslyze (python39Packages.sslyze)

Copy link
Contributor

@thiagokokada thiagokokada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Result of nixpkgs-review pr 144939 run on x86_64-darwin 1

2 packages failed to build:
  • python39Packages.nassl
  • sslyze (python39Packages.sslyze)
2 packages built:
  • python38Packages.nassl
  • python38Packages.sslyze

Error log: http://ix.io/3Ef9

Copy link
Contributor

@thiagokokada thiagokokada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to soft approve here since I think somebody else should also review the changes.

In my eyes the changes are good. At least the user will have to take a conscious decision of using a software that depends on insecure versions of OpenSSL.

@risicle
Copy link
Contributor Author

risicle commented Nov 7, 2021

@thiagokokada What macos version is this? Does it build from master on this machine?

@thiagokokada
Copy link
Contributor

thiagokokada commented Nov 7, 2021

@thiagokokada What macos version is this? Does it build from master on this machine?

10.15.

master fails while trying to apply a patch (I assume on openssl). Error log: http://ix.io/3Efp.

@risicle
Copy link
Contributor Author

risicle commented Nov 7, 2021

Oh of course that's the bug I'm trying to fix.

Could it have been the "trying to build the python 3.8 and 3.9 versions at the same time and colliding on ports" darwin problem?

@thiagokokada
Copy link
Contributor

thiagokokada commented Nov 7, 2021

Result of nixpkgs-review pr 144939 run on x86_64-darwin 1

4 packages built:
  • python38Packages.nassl
  • python38Packages.sslyze
  • python39Packages.nassl
  • sslyze (python39Packages.sslyze)

Seems like a flaky test maybe?

Oh of course that's the bug I'm trying to fix.

Could it have been the "trying to build the python 3.8 and 3.9 versions at the same time and colliding on ports" darwin problem?

Also possible.

opensslStatic = (openssl.override nasslOpensslArgs).overrideAttrs (
opensslStatic = (openssl_1_1.override nasslOpensslArgs).overrideAttrs (
oldAttrs: rec {
name = "openssl-${version}";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name = "openssl-${version}";
pname = "openssl";

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it needs name to fill out the download url.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The openssl package in nixpkgs already uses pname + version in the download url. Maybe we should update it or not. I am not sure. Marking as unresolved so that it is clear where I wrote a comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overrideAttrs needs to override name for the changes to be reflected. pname+version will be concatentated under name when invoked with stdenv.mkDerivation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done at multiple places wrong. I think this should change internally because it is very unintuitive.

@risicle
Copy link
Contributor Author

risicle commented Nov 7, 2021

Unfortunately marking it with knownVulnerabilities stops ofborg from building it and that's my only way of testing it on aarch64.

@thiagokokada
Copy link
Contributor

Unfortunately marking it with knownVulnerabilities stops ofborg from building it and that's my only way of testing it on aarch64.

You can use this trick to build to other architectures: https://nixos.wiki/wiki/NixOS_on_ARM#Compiling_through_QEMU

It is slow, but in this case I don't think it will take that much time.

@risicle
Copy link
Contributor Author

risicle commented Nov 9, 2021

Ok, I think this is a better state than previous, so am merging.

@risicle
Copy link
Contributor Author

risicle commented Nov 9, 2021

(I was going to try simply omitting the legacy openssl on aarch64 thinking it might be optional, but I don't think it is)

@risicle risicle merged commit f614f94 into NixOS:master Nov 9, 2021
@veehaitch
Copy link
Member

nassl is a Python library which was primarily created for sslyze which is an SSL/TLS security scanner. It relies on an outdated OpenSSL to perform insecure negotiations, algorithms, etc. I agree that we should make sure other packages do not depend on it without an explicit opt-in. Still, it would be nice to allow for using sslyze without the warning that this package is insecure—this seems like a false conclusion, at least for the case of sslyze.

@risicle
Copy link
Contributor Author

risicle commented Nov 10, 2021

The thing is, making any of those conclusions involves us making judgements ourselves what constitutes a vulnerability that is "ok". You mention that nassl inherently uses insecure connections to do its' job - sure - but some of the CVEs involved have potential consequences beyond "your crypto could be broken". What we would not want is people using a vulnerable nassl and scanning a malicious site only to end up with remote (er.. local in this case) code execution without having been warned. I don't think we have the resources to be able to rule out this possibility (and reassess every time a new openssl vulnerability is revealed).

I understand your reservations though and it did hurt a bit slapping this knownVulnerabilties on.

@veehaitch
Copy link
Member

Fair enough, thanks for the quick reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: python Python is a high-level, general-purpose programming language. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants