FRAUD DETECTION module
Admin Guide
Section titled “Admin Guide”Overview
Section titled “Overview”This module provides a way to prevent some basic fraud attacks. Alerts are provided through return codes and events.
Monitorized Stats
Section titled “Monitorized Stats”Basically, this module watches the following parameters:
- Total calls
- Calls per minute
- Concurrent calls
- Number of sequential calls
- Call duration
Each of the above parameters is monitored for every user and every called prefix separately. The stats are altered whenever the check_fraud function is called. The function assumes a new call is made, and checks the called number against all the rules from the supplied profile. The rule’s prefix is considered to be the called prefix which along with the provided user will be used to monitor values for the 5 parameters.
Fraud rules
Section titled “Fraud rules”A rule is a set of two thresholds (warning and critical thresholds) for each of the five parameters (as described above) and is only available for a specified prefix. Further more, a rule will only match between the indicated hours in the indicated days of the week (similarly to a dr rule). A fraud profile is simply a group of fraud rules and is used to only to limit the list of rules to match when calling the check_fraud function.
Dependencies
Section titled “Dependencies”OpenSIPS modules
Section titled “OpenSIPS modules”The following modules must be loaded before this module:
- drouting
- dialog
External libraries or applications
Section titled “External libraries or applications”The following libraries or applications must be installed before running OpenSIPS with this module:
- none.
Exported Parameters
Section titled “Exported Parameters”db_url (string)
Section titled “db_url (string)”Database where to load the rules from.
Default value is “NULL”. At least one db_url should be defined for the fraud_detection module to work.
...modparam("fraud_detection", "db_url", "mysql://user:passwb@localhost/database")...use_utc_time (integer)
Section titled “use_utc_time (integer)”Set this parameter to non-zero in order to enable UTC-based interval matching and statistics resets, rather than local time-based.
The default value is “0” (use local time).
...modparam("fraud_detection", "use_utc_time", 1)...table_name (string)
Section titled “table_name (string)”If you want to load the rules from the database you must set this parameter as the database name.
The default value is “fraud_detection”.
...modparam("fraud_detection", "table_name", "my_fraud")...rid_col (string)
Section titled “rid_col (string)”The column’s name in the database storing the fraud rule’s id.
Default value is “ruleid”.
...modparam("fraud_detection", "rid_col", "theruleid"")...pid_col (string)
Section titled “pid_col (string)”The column’s name in the database storing the fraud profile’s id.
Please keep in mind that a profile is merely a set of rules.
Default value is “profileid”.
...modparam("fraud_detection", "pid_col", "profile"")...prefix_col (string)
Section titled “prefix_col (string)”The column’s name in the database storing the prefix for which the fraud rule will match.
Default value is “prefix”.
...modparam("fraud_detection", "prefix_col", "myprefix")...start_h (string)
Section titled “start_h (string)”The column’s name in the database storing the the start time of the interval in which the rule will match.
The time needs to be specified as string using the format: “HH:MM”
Default value is “start_hour”.
...modparam("fraud_detection", "start_h", "the_start_time")...end_h (string)
Section titled “end_h (string)”The column’s name in the database storing the the end time of the interval in which the rule will match.
The time needs to be specified as string using the format: “HH:MM”
Default value is “end_hour”.
...modparam("fraud_detection", "end_h", "the_end_time")...days_col (string)
Section titled “days_col (string)”The column’s name in the database storing the week days in which the fraud rule’s interval is available.
The daysoftheweek needs to be specified as a string containing a list of days or intervals. Each day must be specified using the first three letters of its name. A valid string would be: “Fri-Mon, Wed, Thu”
Default value is “daysoftheweek”.
...modparam("fraud_detection", "days_col", "days")...cpm_thresh_warn_col (string)
Section titled “cpm_thresh_warn_col (string)”The column’s name in the database storing the warning threshold value for calls per minute.
Default value is “cpm_warning”.
...modparam("fraud_detection", "cpm_thresh_warn_col", "cpm_warn_thresh")...cpm_thresh_crit_col (string)
Section titled “cpm_thresh_crit_col (string)”The column’s name in the database storing the critical threshold value for calls per minute.
Default value is “cpm_critical”.
...modparam("fraud_detection", "cpm_thresh_crit_col", "cpm_crit_thresh")...calldur_thresh_warn_col (string)
Section titled “calldur_thresh_warn_col (string)”The column’s name in the database storing the warning threshold value for call duration.
Default value is “call_duration_warning”.
...modparam("fraud_detection", "calldur_thresh_warn_col", "calldur_warn_thresh")...calldur_thresh_crit_col (string)
Section titled “calldur_thresh_crit_col (string)”The column’s name in the database storing the critical threshold value for call duration.
Default value is “call_duration_critical”.
...modparam("fraud_detection", "calldur_thresh_crit_col", "calldur_crit_thresh")...totalc_thresh_warn_col (string)
Section titled “totalc_thresh_warn_col (string)”The column’s name in the database storing the warning threshold value for the number of total calls.
Default value is “total_calls_warning”.
...modparam("fraud_detection", "totalc_thresh_warn_col", "totalc_warn_thresh")...totalc_thresh_crit_col (string)
Section titled “totalc_thresh_crit_col (string)”The column’s name in the database storing the critical threshold value for the number of total calls.
Default value is “total_calls_critical”.
...modparam("fraud_detection", "totalc_thresh_crit_col", "totalc_crit_thresh")...concalls_thresh_warn_col (string)
Section titled “concalls_thresh_warn_col (string)”The column’s name in the database storing the warning threshold value for the number of concurrent calls.
Default value is “concurrent_calls_warning”.
...modparam("fraud_detection", "concalls_thresh_warn_col", "concalls_warn_thresh")...concalls_thresh_crit_col (string)
Section titled “concalls_thresh_crit_col (string)”The column’s name in the database storing the critical threshold value for the number of concurrent calls.
Default value is “concurrent_calls_critical”.
...modparam("fraud_detection", "concalls_thresh_crit_col", "concalls_crit_thresh")...seqcalls_thresh_warn_col (string)
Section titled “seqcalls_thresh_warn_col (string)”The column’s name in the database storing the warning threshold value for the number of sequential calls.
Default value is “sequential_calls_warning”.
...modparam("fraud_detection", "seqcalls_thresh_warn_col", "seqcalls_warn_thresh")...seqcalls_thresh_crit_col (string)
Section titled “seqcalls_thresh_crit_col (string)”The column’s name in the database storing the critical threshold value for the number of sequential calls.
Default value is “sequential_calls_critical”.
...modparam("fraud_detection", "seqcalls_thresh_crit_col", "seqcalls_crit_thresh")...Exported Functions
Section titled “Exported Functions”check_fraud(user, number, profile_id)
Section titled “check_fraud(user, number, profile_id)”This method should be called each time a given user calls a given number. It will try to match a fraud rule within de given fraud profile and update the stats (see above). Furthermore, the stats will be checked against the rule’s thresholds. If any of the stats is above it’s threshold value the appropriate event will also be raised (see further details below).
Meaning of the parameters is as follows:
- user (string) - the user who is making the call. Please keep in mind that the user doesn’t have to be registered. This string is only used to keep different stats for different registered users.
- number (string) - the number the user is calling to.
- profile_id (int) - the fraud profile id (i.e. the subset of fraud rules) in which to try and find a matching fraud rule.
The meaning of the return code is as follows:
- 2 - no matching fraud rule was found
- 1 - a matching rule was found, but there is no parameter above the rule’s threshlod, i.e - everything is ok
- -1 - there is a parameter above the warning threshold value. Check the raised event for more info
- -2 - there is a parameter above the critical threshold value. Check the raised event for more info
- -3 - something went wrong (internal mechanism failed)
This function can be used from REQUEST_ROUTE and ONREPLY_ROUTE.
Exported MI Functions
Section titled “Exported MI Functions”show_fraud_stats
Section titled “show_fraud_stats”Show the current statistics for all dials of a user to a prefix.
Name: show_fraud_stats
Parameters:
- user
- prefix
fraud_reload
Section titled “fraud_reload”Reload the all the fraud rules.
Name: fraud_reload
Parameters: none
Exported Events
Section titled “Exported Events”E_FRD_WARNING
Section titled “E_FRD_WARNING”This event is raised whenever one of the 5 monitored parameters is above the warning threshold value
Parameters:
- param - the name of the parameter.
- value - the current value of the parameter.
- threshold - the warning threshold value.
- user - the user who initiated the call.
- called_number - the number that was called.
- rule_id - the id of the fraud rule that matched when the call was initiated
E_FRD_CRITICAL
Section titled “E_FRD_CRITICAL”This event is raised whenever one of the 5 monitored parameters is above the warning threshold value
Parameters:
- param - the name of the parameter.
- value - the current value of the parameter.
- threshold - the warning threshold value.
- user - the user who initiated the call.
- called_number - the number that was called.
- rule_id - the id of the fraud rule that matched when the call was initiated
Contributors
Section titled “Contributors”By Commit Statistics
Section titled “By Commit Statistics”Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)
| # | Name | DevScore | Commits | Lines++ | Lines— |
|---|---|---|---|---|---|
| 1. | Liviu Chircu (@liviuchircu) | 41 | 33 | 330 | 267 |
| 2. | Andrei Datcu (@andrei-datcu) | 38 | 11 | 2671 | 241 |
| 3. | Stefan Darius (@dariusstefan) | 12 | 4 | 641 | 92 |
| 4. | Razvan Crainea (@razvancrainea) | 8 | 6 | 14 | 11 |
| 5. | Vlad Patrascu (@rvlad-patrascu) | 8 | 5 | 73 | 114 |
| 6. | Bogdan-Andrei Iancu (@bogdan-iancu) | 7 | 5 | 20 | 31 |
| 7. | Ionut Ionita (@ionutrazvanionita) | 3 | 1 | 21 | 6 |
| 8. | Peter Lemenkov (@lemenkov) | 3 | 1 | 1 | 1 |
(1) DevScore = author_commits + author_lines_added / (project_lines_added / project_commits) + author_lines_deleted / (project_lines_deleted / project_commits)
(2) including any documentation-related commits, excluding merge commits
(3) ignoring whitespace edits, renamed files and auto-generated files
By Commit Activity
Section titled “By Commit Activity”| # | Name | Commit Activity |
|---|---|---|
| 1. | Stefan Darius (@dariusstefan) | Jun 2026 - Jul 2026 |
| 2. | Razvan Crainea (@razvancrainea) | Feb 2015 - Jun 2026 |
| 3. | Liviu Chircu (@liviuchircu) | Mar 2015 - Aug 2020 |
| 4. | Vlad Patrascu (@rvlad-patrascu) | May 2017 - Apr 2019 |
| 5. | Bogdan-Andrei Iancu (@bogdan-iancu) | Oct 2014 - Apr 2019 |
| 6. | Peter Lemenkov (@lemenkov) | Jun 2018 - Jun 2018 |
| 7. | Ionut Ionita (@ionutrazvanionita) | Jan 2016 - Jan 2016 |
| 8. | Andrei Datcu (@andrei-datcu) | Aug 2014 - Sep 2014 |
(1) including any documentation-related commits, excluding merge commits
Documentation
Section titled “Documentation”Contributors
Section titled “Contributors”Last edited by: Razvan Crainea (@razvancrainea), Liviu Chircu (@liviuchircu), Vlad Patrascu (@rvlad-patrascu), Peter Lemenkov (@lemenkov), Bogdan-Andrei Iancu (@bogdan-iancu), Andrei Datcu (@andrei-datcu).
License
Section titled “License”All documentation files (i.e. .md extension) are licensed under the Creative Common License 4.0