Class IpReputation

java.lang.Object
com.aoapps.hodgepodge.net.IpReputation

public class IpReputation extends Object
Tracks IP reputation for use by any number of services.

The lifecycle:

  1. init(java.net.InetAddress), returns IpReputation.Connection - establishes a new context for tracking one specific service interaction.
  2. Connection:
    1. IpReputation.Connection.accept()
    2. IpReputation.Connection.abort()
    3. IpReputation.Connection.started()
    4. IpReputation.Connection.fail()
    5. IpReputation.Connection.success()
  3. Bad score decays once per hour.
  4. Blocking is done at a bad score of REJECT_BAD_SCORE, limiting attempts (both serial and concurrent).
  5. Bad score is capped to MAX_BAD_SCORE for a maximum of a UNBLOCK_HOURS-hour block.

Future ideas (in no particular order):

  1. Sortable columns in simple aoadmin-only web interface to view current statistics for the VNC tracker.
  2. Using hard-coded values; only make configurable when first needed.
  3. Concurrency through ConcurrentMap and AtomicInteger.
  4. Evict older records, with lower "bad" scores, when a fixed number of records are reached. (to limited maximum heap usage).
  5. Be able to remove blocks from the aoadmin interface.
  6. Track "Good" scores, too.
  7. Add a "boost" method, which would add some "Good" reputation from an external source, such as successful website login or access to remote console control panels. Have to consider consequences of this - don't want a bad guy with access to boost themselves unlimited service password attempts. Could limit to one boost per time period or session. However, the per-attempt delays might be sufficient to mitigate this already. Boost an be weaker than Connection.success(), and only apply to the /32 or /128.
  8. Track good/bad scores per different network ranges, both IPv4 and IPv6 supported:
    1. For IPv4, tracking /32 through /24, at every level (/32, /31, …, /25, /24).
    2. For IPv6, tracking /128 through /32, at every 4th level (/128, /124, …, /36, /32). Exact details to be determined later. Could be every 4th from /128 to /64, then others like /56, /48
    3. Scores are added and removed across all the levels.
    4. For allow/deny decision, check tightest range first (/32 or /128): if (bad - good) > deny_threshold, deny. If (bad - good) < allow_threshold, allow. Otherwise check the next level up. When allow levels checked and no threshold, would be UNCERTAIN (Link enum).
    5. At all prefixes, bad scores would have a maximum value where the decay would not block more than 24 hours.
    6. At all prefixes, good scores would have a maximum value where their reputation can persist longer, maybe a month?
    7. But scores for increasingly broader network ranges should have caps and decay such that the reputation effects do not last as long.
    8. Maybe the positive score decays more quickly by prefix. So a positive /32 could last up to 32 days, while the positive /24 could last much less time. Basically, either cap the max good score by prefix (preferred), or decay more quickly by prefix.
    9. Bound the downside of the difference. One good login could result in multiple bad attempts: 30 days reputation, slower decay, +2 good versus +1 bad, all multiple to the number of attempts that could be made. But, the number of attempts would remain bounded. A bad guy with one good login could use that to magnify their attempts. However, like the "boost" idea, the per-attempt delays might be sufficient to mitigate this already.
  9. Support IPv6 (including mapped IPv4 being converted to IPv4 internally)
  10. Support persistence. If storing in local filesystem, consider consequences of Tomcat parallel deployment. More enterprisey solution would be a reputation service that centralizes across multiple services, but this would begin to overlap the existing, and more complicated, AOServ IP Reputation system that blocks at edge routers.
  11. Bad scores decay more quickly, maybe once per hour and in a quantity scaled by (33-prefix) (/32 would decay one per hour, /31 would decay two per hour, /24 would decay 9 per hour /24 8 per hour).
  12. Good scores decay more slowly, maybe once per 10 hours or similar.
  13. Use this feature for other Java endpoints, such as aoserv-daemon, aoserv-master, and NOC RMI.
  14. When background clean-up is triggered, clean the immediate record being processed (if any), then delegate background clean-up to the provided task executor. API users would have to pass-in the executor, which could simply by Thread::new or could be an unbouded executor from ao-concurrent.
  15. Beyond reputation, add rate-limits per-host, and per-network prefix ranges. These rate limits would even affect those successfully performing the operations. The rate limit allowed could be affected by the currently effective good/bad scores.
  16. Use the reputation system for login forms and servlet filter for public facing sites. In particular, could integrate well with the rate limiting idea.
Author:
AO Industries, Inc.
  • Constructor Details

  • Method Details

    • getRecordsSnapshot

      public Map<InetAddress,Integer> getRecordsSnapshot()
      Gets a snapshot of the current reputation records with a badScore > 0.
      Returns:
      Unmodifiable snapshot map from address to bad score in insertion order.
    • init

      public IpReputation.Connection init(InetAddress address)