Code Monkey home page Code Monkey logo

ssh_scan_api's Introduction

WARNING Deprecated - please use ssh_scan from command-line

ssh_scan_api

Build Status Code Climate Gem Version Join the chat at https://gitter.im/mozilla-ssh_scan/Lobby Coverage Status

A web api to scale ssh_scan operations

Setup

To install and run from source, type:

# clone repo
git clone https://github.com/mozilla/ssh_scan_api.git
cd ssh_scan_api

# install rvm,
# you might have to provide root to install missing packages
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable

# install Ruby 2.3.1 with rvm,
# again, you might have to install missing devel packages
rvm install 2.3.1
rvm use 2.3.1

# resolve dependencies
gem install bundler
bundle install

./bin/ssh_scan_api

ssh_scan as a command-line tool?

This project is focused on providing ssh_scan as a service/API.

If you would like to run ssh_scan from command-line, checkout the ssh_scan project.

Rubies Supported

This project is integrated with travis-ci and is regularly tested to work with multiple rubies.

To checkout the current build status for these rubies, click here.

Contributing

If you are interested in contributing to this project, please see CONTRIBUTING.md.

Credits

Sources of Inspiration for ssh_scan

  • Mozilla OpenSSH Security Guide - For providing a sane baseline policy recommendation for SSH configuration parameters (eg. Ciphers, MACs, and KexAlgos).

ssh_scan_api's People

Contributors

april avatar hvardhanx avatar mozilla-github-standards avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ssh_scan_api's Issues

Port bug

/root/code/ssh_scan/lib/ssh_scan/result.rb:38:in `port=': Invalid attempt to set port to a non-port value (ArgumentError)
        from /root/code/ssh_scan/lib/ssh_scan/scan_engine.rb:26:in `scan_target'
        from /root/code/ssh_scan/lib/ssh_scan/scan_engine.rb:171:in `block (2 levels) in scan'

Should we allow scanning localhost/127/RFC1918?

I was thinking this would be a no-brainer, but then again, I kind of want to scan localhost. I suppose maybe this could be just adding features that describe what can/cannot be scanned, in case someone runs this on their edge and wants to prevent internal scanning from external sources.

I suppose one simple solution would be to allow the ability to restrict RFC1918 ranges in the API config and reject any submission requests for that. This could be just a set of CIDRs or individual addrs that we check before we scan.

It's currently not an issue as we host the service in a VPS, but would be more relevant if we self-hosted.

Caching does not appear to be working

We implemented caching at one point, but I've received reports from people stating that they are getting unique UUIDs for repeated scans of the same property.

It's possible we're doing wrong, or the config it's set properly, but creating this bug to verify so it's not forgotten.

Go Serverless? (FaaS)

This is more of an experimental thing about whether we could make ssh_scan_api a server-less function.

What would it take?

  • Re-writing the API as a Lambda service
  • Hosting the Data storage container somewhere in AWS (probably)
  • Maybe we could even make workers that are server-less functions

Drop compression from the modern policy

This really doesn't have any security implications, and we might have configuration limitations with openssh (the most popular ssh lib).

By removing it, we will effectively not care what they have for compression settings.

Consume SSH endpoints from R7's sonar dataset

Doing broad internet scanning to find SSH ports is time consuming and simply outside the scope of this project. However, using the tool against known SSH endpoints that are already known (like the sonar dataset) might be helpful from a research and progress tracking perspective that would also help inform decision making around policy creation. It's also helpful for finding and fixing bugs in the engine by giving it more examples to work against.

To do this, it likely depends on running a research instance of the infra or just having a low priority queue where we can dump large quantities of hosts to scan (#77)

Add Service Monitoring

Usually, April is the first person to hear about Mozilla SSH Observatory issues because she's working Observatory stuff a lot more than I. However, these issues generally boil down to one of two areas, which I should just add monitoring to let me know, so I'm the first person to know.

1.) Alert me when the site is not responding (this is usually nginx restarting and failing or a failed lets encrypt renew)
2.) Alert me when the queues are non-zero and not changing (this is usually an indication that something is broken or site abuse)

getaddrinfo: Name or service not known (SocketError)

I, [2017-06-05T20:05:25.287073 #13870] INFO -- : Started job: 2b9baa46-335c-48da-880c-b83e1bc765ab
/usr/local/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/socket.rb:231:in getaddrinfo': getaddrinfo: Name or service not known (SocketError) from /usr/local/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/socket.rb:231:in foreach'
from /usr/local/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/socket.rb:626:in tcp' from /root/code/ssh_scan/lib/ssh_scan/client.rb:21:in connect'
from /root/code/ssh_scan/lib/ssh_scan/scan_engine.rb:53:in scan_target' from /root/code/ssh_scan/lib/ssh_scan/scan_engine.rb:145:in block (2 levels) in scan'

How do we want to deal with scans that failed auth_method detection?

Options...

1.) Investigate further why the auth_method detection isn't working or why the client is erroring
2.) Return a partial result, but fail on compliance for the auth_method part
3.) In cases where we can't determine compliance, maybe we give them a pass on auth_method detection

Cases I think of that could cause this would be services that expect client-side certs or have some sort of MFA requirement, but pokeinthe.io is a good repro target to work with.

Add rate limiting for unauth'd users

this hasn't been a problem yet, but it's probably worth thinking about and adding some rate-limiting or throttling to prevent single IP DoS scenario.

We could also have a max queue size at anyone time that is X and when that queue limit is hit then we stop queuing scans until the queues subside. Though, this could also make it easier to DoS, so we'll need to make sure that single user limit is less than the global limit.

Make stats interface based on actual DB content

Stats interface is sort of a crude shim right now, would be nice if it looked at the DB and said...

  • How many scans in what state transition? (queued, running, errored, completed)
  • How many scans attempted total?
    ....

Create an InvalidTargetChecker

basically, we're always going to have targets or target matches that we don't want scanned...

#91

Let's make a full-featured invalid target checker that can take a list of invalid targets/regexs to check against to act as a gate keeper.

This should also help in abuse cases where people can send their own blacklist items as data rather than code. Should also make it easier to spec.

Enable ipv6 on prod host

Having some error issues with hosts that support ipv6, but we don't have ipv6 enabled in prod. This issue is to fix that

In progress scan polling returns weak/confusing messaging

Scenario:

1.) I use the API to task a scan
2.) I then poll the API periodically to see when the scan is completed
3.) During that window of waiting for the scan, we provide very little feedback to the end user about what's happening (currently just { scan: "not found" } until the scan comes back)

This is particially due to the currently implemented crude queuing strategy in place where it's not maintaining state or bound to the DB in any way. Once this is DB integrated we should provide active status for the end user so they can bubble that feedback back to the user.

Refactor ssh_scan_worker bin/lib

The workers are not as robust as I would prefer. Things that I think we could do better include...

  • Having a worker manager (that can spin up multiple worker processes in a single command-line run)
  • Have some sort of service recovery (that can make sure if a worker dies/dead-locks that it is respawned)
  • Have some sort of system service (that can ensure service start back up on a reboot)

Add some sort of BATCHED_QUEUE functionality

The idea here is say we want to scan 1000 servers for research purposes, but we know if we do that we might impact a real user sitting in front of a screen.

So this would allow someone the ability to throw those 1000 servers into a lower-priority queue so they can be completed when the normal queue isn't so busy.

Dockerize the ssh_scan_api

This is primarily so I can more easily maintain the production deployment, but I suspect it will open up more doors for viable integration testing.

Should we allow scanning localhost/127

I was thinking this would be a no-brainer, but then again, I kind of want to scan localhost. I suppose maybe this could be just adding features that describe what can/cannot be scanned, in case someone runs this on their edge and wants to prevent internal scanning from external sources.

I suppose one simple solution would be to allow the ability to restrict RFC1918 ranges in the API config and reject any submission requests for that. This could be just a set of CIDRs or individual addrs that we check before we scan.

It's currently not an issue as we host the service in a VPS, but would be more relevant if we self-hosted.

Provide configuration restrictions on what ports can be scanned

Currently, the prod API allows the scanning of really any TCP port. We should probably provide some controls around this that limit it's exposure so people can make their own choices about what ports are acceptable. I say this because some orgs have conventions of splitting say SCM services into SCM + MGMT ssh services, which require alternative ports.

Move production API && DB to AWS

Locallized mongo instances are greate for local testing and such, but for the production deployment, it would be really handy to have the DB live in a very stable place where it can get backups and such in the case of API server corruption resulting in data loss.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.