Giter VIP home page Giter VIP logo

suspicious_login's Introduction

๐Ÿ”ฎ Nextcloud Suspicious Login Detection

Detect and warn about suspicious IPs logging into Nextcloud

Downloads Build Status Dependabot Status

The app is still under development, so itโ€™s time for you to get involved! ๐Ÿ‘ฉโ€๐Ÿ’ป

Installation

Nextcloud 25 and newer

The app is shipped and comes with the installation of Nextcloud Server. No additional steps are necessary.

Nextcloud 24 and older

Old versions of this app remain available through the app store. They can be installed through Nextcloud's app management UI.

Note

Newer versions of the app are not included in the app store since it is now a shipped app.

Releases and CHANGELOGs

As a shipped app:

  • changes are posted within the Nextcloud Server changelog.
  • releases are not posted in this GitHub repository, but they are tagged for code perusal.
  • it is automatically kept up-to-date with each Nextcloud Server release.

How it works

Data collection

Once this app is enabled, it will automatically start tracking (IP, uid) tuples from successful logins on the instance and feed them into the login_address table. This insert operation is executed for the majority of requests (client authenticate on almost all requests) and therefore has to be fast. In a background job, these rows will be transformed into an aggregated format that is suitable for the training of the neural net. The (IP, uid) tuple becomes (IP, uid, first_seen, last_seen, seen) so that we know which (IP, uid) tuple has been seen first and last. The aggregated data is a compressed format of the raw data. The original data gets deleted and thus the database does not need much space for the collected login data.

Neural net

When enough data is collected โ€“ which by default is 60 days (!) โ€“ a first training run can be started.

The app registers a background job that invokes the training once a day. As long as there isn't sufficient data, no trained model is generated.

Manual training

The training can also be invoked via the OCC command line tool:

php -f occ suspiciouslogin:train

This command uses several sensible default that should work for instances of any size. The --stats flag is useful to see the measured performance of the trained model after the training finishes. The duration of the training run depends on the size of the input training set, but is usually between two to 15 minutes.

The full list of parameters, their description and default values can be seen with

php -f occ suspiciouslogin:train --help

Hyper parameter optimization (optional)

To find the best possible parameters for the training it's possible to start a hyper parameter optimization run via the CLI:

php -f occ suspiciouslogin:optimize

This command uses the heuristic simulated annealing algorithm to find optimal parameter sets in the multidimensional parameter space. By default this will do 100 steps consisting of five training runs per step, hence this command might take a few days to execute on large instances. On smaller ones it will also take a few hours.

Login classification

As soon as the first model is trained, the app will start classifying (IP, uid) tuples on login. In contrast to the data collection it won't consider requests authenticated via an app password as suspicious. Should it detect a password login where the (IP, uid) is classified as suspicious by the trained model, it will add an entry to the suspicious_login table, including the timestamp, request id and URL.

Configuration

By default notifications about suspicious logins contain a link (button) to lookup more info about the noted IP address (geography, ISP). This link can be disabled if it isn't desired:

occ config:app:set --value 0 suspicious_login show_more_info_button

Development setup

  1. โ˜ Clone the app into the apps folder of your Nextcloud: git clone https://github.com/nextcloud/suspicious_login.git
  2. ๐Ÿ’ป Run npm i or krankerl up to install the dependencies
  3. ๐Ÿ— To build the Javascript whenever you make changes, run npm run dev
  4. โ˜ Enable the app through the app management of your Nextcloud or run krankerl enable
  5. ๐Ÿ‘ Partytime! Help fix some issues and review pull requests

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.