IBM Security QRadar

 View Only
  • 1.  Is there a way to load regex used by an existing rule from an external source ?

    Posted Thu February 16, 2023 02:18 AM

    We are using rules which check certain properties with regex for the presence of a pattern. 

    As we make frequent changes to these regular expressions we are looking for a way to consume the regex, used by these rules from an external location.

    So far we have not found a useable API Endpoint for injection of content into rules. 

    Do you have any hints how to push/pull the regex from an external source into QRadar Ruleengine ?  

    Regards
    Thomas



    ------------------------------
    SIEM-2020
    ------------------------------


  • 2.  RE: Is there a way to load regex used by an existing rule from an external source ?

    Posted Fri February 17, 2023 03:02 AM

    Hi Thomas,

    At this point of time, I don't think QRadar has anything like this.  It doesn't seem feasible also as parsing CEP measure in milliseconds and the moment you think about external source, network comes into picture which can introduce latency and break the pipeline and rule engine.



    ------------------------------
    Prabir Meher
    ------------------------------



  • 3.  RE: Is there a way to load regex used by an existing rule from an external source ?

    Posted Mon February 20, 2023 02:41 AM

    Hi Prabir,

    I was looking for a way to load the regex into the rule from remote,  not to process the regex remotely.

    Regards
    Thomas



    ------------------------------
    SIEM-2020
    ------------------------------



  • 4.  RE: Is there a way to load regex used by an existing rule from an external source ?

    Posted Mon February 20, 2023 08:46 AM

    Hi Thomas,

    Question for you:

    1. why would you change a regex frequently?  I don't see a reason to change a regex (NOT frequently) until
      1. the payload changes
      2. or it's a greedy regex to which you want to do some optimization
    2. At this point, if at all you need to change regex, you need to change that in the Custom Event Properties window of admin tab.
    3. There is no such way to load the regex into a rule from remote.

    But, I would like to understand your thought process behind this. Do you have any use case / example (with proper data) that you think you can share?



    ------------------------------
    Prabir Meher
    ------------------------------



  • 5.  RE: Is there a way to load regex used by an existing rule from an external source ?

    Posted Fri February 24, 2023 05:21 AM

    Hello Prabir

    the usecase for this request, is that we are very closely watching the donwload Links delivered by some threat actors. 

    They often have simple methods to generate Download-URLs, but they also make frequent changes to these methods.
    Just comparing URLs with values you already know is pretty useless, as the URLs change constantly.
    Once we detect changes in their Link Creation method, we try to create a regex based on the first samples.
    This often helps us to match URLs during the next day(s).
    Our Regex are developed, documented, tested in a central tool which is more valuable for this task that our SIEM (proper right model, history tracking..). 
    SIEM, is just another consumer of the results and should grab the regex without further manual interaction as soon as it is committed. 

    Regards
    Thomas



    ------------------------------
    SIEM-2020
    ------------------------------



  • 6.  RE: Is there a way to load regex used by an existing rule from an external source ?

    Posted Fri February 24, 2023 06:22 AM

    You can achieve this using a Custom AQL function.

    First, you need to create your function - which you can do by following (for example) Jose Bravo's example .. https://www.youtube.com/watch?v=6z8zjXw-xE4

    When doing so, use this XML template as an example:

    ===

    <content>
        <custom_function>
            <namespace>AQL_FILTER</namespace>
            <id>1</id>
            <name>Dynamic_URL_check</name>
            <return_type>boolean</return_type>
            <parameter_types>string</parameter_types>
            <description>URL checker</description>
            <execute_function_name>checkURL</execute_function_name>
            <script_engine>javascript</script_engine>
            <varargs>false</varargs>
            <script>
              function checkURL(in_url) {
                url_match = false;
                if (/.*dodgy.*/.test(in_url)) {
                   url_match = true;
                }
                return url_match;
              }
            </script>
            <username>admin</username>
        </custom_function>
    </content>

    ===

    Once that has uploaded sucessfully, you can use the new AQL filter in a rule like this:

    ===

    Rule Description
          Apply ZXZ_CUSTOM_AQL_TEST on events which are detected by the Local system
    and when the event(s) were detected by one or more of testleef
    and when the event matches AQL_FILTER::Dynamic_URL_check(test_url) AQL filter query
     
    Rule Actions
          

        Set Severity to 10
        Set Credibility to 10
        Set Relevance to 10

    This Rule will be: Enabled 

    ===

    To modify the test, all you need to do is change the JavaScript in the Custom AQL filter, upload it and force the rules to reload.

    Now, the way the video shows to do it is using the Content Management Tool (CMT) - but you can also manage Custom AQL Functions with the REST-API content extensions endpoints. (under "/config/extension_management"). 

    You can then force a rule reload by toggling any rule using the REST-API endpoint "/analytics/ade_rules/{id}"

    pfh



    ------------------------------
    Paul Ford-Hutchinson
    ------------------------------



  • 7.  RE: Is there a way to load regex used by an existing rule from an external source ?

    Posted Mon February 27, 2023 05:09 AM

    Hello Paul, 

    thank you for the precise description and the additiona hints about API endpoints.  This looks like a valid approach to our requirement. 
    We will definitly try to implement it this way and update the rules via Rest-API. 
    We also have to check if the performance impact of the custom AQL function is acceptable. 

    Regards
    Thomas



    ------------------------------
    SIEM-2020
    ------------------------------



  • 8.  RE: Is there a way to load regex used by an existing rule from an external source ?

    Posted Mon March 06, 2023 08:03 AM


    We received a hint which allowed us to implement this requirement in an even easy way and I want to share this option. 

    The approach is, to store the regex in a refmap, and use an AQL to load the value from the refmap and use it for pattern matching.

    The steps in detail are:
    - Use Reference Data Management (or API) to create a new refmap of Type ALN . 
    - Use Reference Data Management (or API) to add a new record with a unique key (here 'regexid') and the regex (here '.*testdomain.com.*' in the value field 
    - write an AQL query which performs the match of the regex against the desired field.

    For example 

    SELECT * , URL, REFERENCEMAP('my_map_regex','regexid') as regexid from events
    WHERE URL <> NULL
    AND (URL matches REFERENCEMAP('my_map_regex','regexid'))
    LAST 5 MINUTES
    - A similar AQL can now be used to write a Rule.
    - The regex can be updated by Reference Data Management (or API) by just overwriting the value field. 
      The key needs to stay unchanged, as it is referenced by the AQL.

    we came to the conclusion that the performance of this refmap based query ist almost similar to that of an AQL without refmap. For example
    SELECT * , URL from events
    WHERE URL <> NULL
    AND (URL matches '.*testdomain.*')

    Hope that helps.      Thanks to J. Sattelmair from the IBM Team in our territory for this hint.

    Regards
    Thomas


    ------------------------------
    SIEM-2020
    ------------------------------



  • 9.  RE: Is there a way to load regex used by an existing rule from an external source ?

    Posted Mon March 06, 2023 08:30 AM

    Neat.  As long as you have only one (or, indeed, a fixed number) regex to match that looks like a great solution.



    ------------------------------
    Paul Ford-Hutchinson
    ------------------------------