Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DoS on ancestry POST causes SIGSEGV #828

Closed
peacocb opened this issue Jul 31, 2019 · 1 comment · Fixed by #829
Closed

DoS on ancestry POST causes SIGSEGV #828

peacocb opened this issue Jul 31, 2019 · 1 comment · Fixed by #829
Labels
kind/bug things are not as they seem

Comments

@peacocb
Copy link
Contributor

peacocb commented Jul 31, 2019

Description of Problem / Feature Request

When a large number of connections (around 1000) are made to Clair with each performing a POST on the ancestry url (when the database is being populated with test data for example), Clair will terminate with a panic (SIGSEGV)

Expected Outcome

Clair should handle multiple connections gracefully.

Actual Outcome

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x77c526]

goroutine 78546 [running]:
github.com/coreos/clair/database.FindAncestryAndRollback(0xc0f240, 0xc000142cd0, 0xc0014ed280, 0x19, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /data/git/va/go/src/github.com/coreos/clair/database/dbutil.go:143 +0x86
github.com/coreos/clair.IsAncestryCached(0xc0f240, 0xc000142cd0, 0xc0014ed280, 0x19, 0xc0042e56e0, 0x2, 0x2, 0xb2f7ff, 0xfca1d16886aa84b2, 0xc0042d32c0)
    /data/git/va/go/src/github.com/coreos/clair/ancestry.go:326 +0x83
github.com/coreos/clair/api/v3.(*AncestryServer).PostAncestry(0xc00013fc40, 0x7f8e0803cf60, 0xc000127a10, 0xc002710500, 0xc00013fc40, 0xc165e0, 0xc0042d32c0)
    /data/git/va/go/src/github.com/coreos/clair/api/v3/rpc.go:79 +0x185
github.com/coreos/clair/api/v3/clairpb._AncestryService_PostAncestry_Handler.func1(0x7f8e0803cf60, 0xc000127a10, 0xaaec80, 0xc002710500, 0xc000296050, 0xc00370ef60, 0xc0000c6b98, 0xc0029d0270)
    /data/git/va/go/src/github.com/coreos/clair/api/v3/clairpb/clair.pb.go:912 +0x86
github.com/coreos/clair/vendor/github.com/grpc-ecosystem/go-grpc-prometheus.UnaryServerInterceptor(0x7f8e0803cf60, 0xc000127a10, 0xaaec80, 0xc002710500, 0xc00370ef40, 0xc00370ef60, 0xc0000c6c28, 0x40e208, 0x50, 0xad44c0)
    /data/git/va/go/src/github.com/coreos/clair/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/server.go:29 +0xb5
github.com/coreos/clair/api/v3/clairpb._AncestryService_PostAncestry_Handler(0xa66520, 0xc00013fc40, 0x7f8e0803cf60, 0xc000127a10, 0xc000296000, 0xb46008, 0x0, 0x0, 0x4172aa, 0x7f8e08f4bf00)
    /data/git/va/go/src/github.com/coreos/clair/api/v3/clairpb/clair.pb.go:914 +0x158
github.com/coreos/clair/vendor/google.golang.org/grpc.(*Server).processUnaryRPC(0xc000175900, 0xc178a0, 0xc001c16dc0, 0xc003523a00, 0xc000229410, 0x10a20d8, 0xc0029d0270, 0x0, 0x0)
    /data/git/va/go/src/github.com/coreos/clair/vendor/google.golang.org/grpc/server.go:791 +0x94c
github.com/coreos/clair/vendor/google.golang.org/grpc.(*Server).handleStream(0xc000175900, 0xc178a0, 0xc001c16dc0, 0xc003523a00, 0xc0029d0270)
    /data/git/va/go/src/github.com/coreos/clair/vendor/google.golang.org/grpc/server.go:991 +0x12b5
github.com/coreos/clair/vendor/google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc001b2eb90, 0xc000175900, 0xc178a0, 0xc001c16dc0, 0xc003523a00)
    /data/git/va/go/src/github.com/coreos/clair/vendor/google.golang.org/grpc/server.go:561 +0x9f
created by github.com/coreos/clair/vendor/google.golang.org/grpc.(*Server).serveStreams.func1

Environment

  • Clair version/image: latest master branch
  • Clair client name/version: latest master branch
  • Host OS: Ubuntu
  • Kernel (e.g. uname -a): 4.18.0-25-generic
  • Kubernetes version (use kubectl version): 1.13.6
  • Helm version (use helm version): 2.14.1
  • Network/Firewall setup: Vyatta
@peacocb
Copy link
Contributor Author

peacocb commented Jul 31, 2019

FindAncestryAndRollback() in dbutil.go should only use the tx variable after the error checking from the datastore.Begin() call, not before.

https://github.com/coreos/clair/blob/517e3e5b2b149703b8519c97b17abbe54b13350c/database/dbutil.go#L143

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug things are not as they seem
Development

Successfully merging a pull request may close this issue.

2 participants