
<p>runZero scans capture a rich dataset of information about all of the assets in your environment and the services running on them. Once gathered, you can run queries on this data to identify points of interest.</p>
<p>A few common use cases include:</p>
<ul>
<li>Identifying network misconfigurations</li>
<li>Identifying potential vulnerabilities</li>
<li>Finding new open services</li>
</ul>
<h2 id="alerting-queries-audience">Who is this playbook for and why?</h2>
<ul>
<li><strong>Security teams</strong> who want to reduce the number of misconfigurations and potential vulnerabilities in their environment, or are interested in identifying new services that could be malicious.</li>
<li><strong>IT teams</strong> who want to ensure their teams are following standard procedures when making updates in their environment.</li>
</ul>
<h2 id="alerting-queries-solution">How will runZero help?</h2>
<p>runZero is able to safely scan your entire network with benign traffic, so it has complete visibility into assets and services running in your network. This allows you to find misconfigurations, potential vulnerabilities, and new services that you would not see in other tools.</p>
<h2 id="alerting-queries-overview">What will I need to do?</h2>
<p>In order to alert on asset and/or service updates, you will need to take the following steps:</p>
<ol>
<li>Identify queries of interest, such as:
<ul>
<li><a href="/docs/playbooks/alerting-on-queries/#alerting-queries-unnecessary-public">Network misconfigurations</a></li>
<li><a href="/docs/playbooks/alerting-on-queries/#vulnerable-application-printerlogic-web-service">Potential vulnerabilities</a></li>
<li><a href="/docs/playbooks/alerting-on-queries/#alerting-queries-unnecessary-public">New services</a></li>
</ul>
</li>
<li>Create an <a href="/docs/creating-alert-templates/">alert template</a>.</li>
<li>Configure a <a href="/docs/rules-engine/#rules-channels">notification channel</a>.</li>
<li>Create <a href="/docs/rules-engine/#create-a-rule">rules</a>.</li>
</ol>
<h2 id="alerting-queries-prereqs">Prerequisites</h2>
<ul>
<li>Build a <a href="/docs/playbooks/building-complete-asset-inventory/">complete asset inventory</a>.</li>
</ul>
<h2 id="alerting-queries-steps">Steps to implement</h2>
<p>The following are step-by-step instructions for configuring a notification rule based on a query.</p>
<h3 id="alerting-queries-step-1">Identify queries of interest</h3>
<ol>
<li>Go to the <a href="https://console.runzero.com/inventory">Inventory</a> page in the runZero console.</li>
<li>Run <a href="/docs/playbooks/alerting-on-queries/#alerting-queries-samples">sample queries</a> to identify ones that meet your needs.</li>
<li>Once you have identified a query of interest, you can add filters until it is ready to be used for alerting on new matches:
<ul>
<li><a href="/docs/search-query-assets/">Asset inventory filters</a></li>
<li><a href="/docs/search-query-services/">Service inventory filters</a></li>
</ul>
</li>
</ol>
<h3 id="alerting-queries-step-2">Configure an alert template</h3>
<ol>
<li>Go to <strong>Alerts</strong> &gt; <strong>Templates</strong> and select <strong>Create Template</strong>.</li>
<li>Provide a <strong>Name</strong>.</li>
<li>Select a <strong>Template type</strong>.</li>
<li>Choose a <strong>Subject line for message</strong>.</li>
<li>Format the <strong>Body of message</strong>.</li>
<li>Click <strong>Save Template</strong>.</li>
</ol>
<h3 id="alerting-queries-step-3">Configure a notification channel</h3>
<ol>
<li>Go to <strong>Alerts</strong> &gt; <strong>Channels</strong> and select <strong>Create Channel</strong>.</li>
<li>Enter a <strong>Name</strong>.</li>
<li>Select a <strong>Channel type</strong>.
<ul>
<li>If Email, enter the <strong>Email address</strong> that will receive notifications.</li>
<li>If Webhook, enter the <strong>Webhook URL</strong> and any <strong>Additional headers</strong> that may be required for the notification.</li>
</ul>
</li>
<li>Select <strong>Save Channel</strong>.</li>
</ol>
<h3 id="alerting-queries-step-4">Configure an alert rule</h3>
<ol>
<li>Go to <strong>Alerts</strong> &gt; <strong>Rules</strong> and select <strong>Create Rule</strong>.</li>
<li>Select <code>asset-query-results</code> for asset queries or <code>service-query-results</code> for service queries.</li>
<li>Select <strong>Configure Rule</strong>.</li>
<li>Provide a <strong>Name</strong> for the new rule.</li>
<li>Select appropriate <strong>Conditions</strong> for the rule. By default, <strong>Any</strong> organization and <strong>Any</strong> site will be selected. The <strong>Query</strong> will be the query you used in the earlier steps.</li>
<li>Select the <strong>Notification channel</strong> that you created.</li>
<li>Select the <strong>Notification template</strong> that you created.</li>
<li>Ensure that <strong>Enabled</strong> is checked and click <strong>Save Rule</strong>.</li>
</ol>
<h2 id="alerting-queries-samples">Sample queries</h2>
<p>You can use the following sample queries to help find network misconfigurations, potential vulnerabilities, and new services.</p>
<h3 id="alerting-queries-unnecessary-public">Unnecessary public facing services</h3>
<h4 id="identify-non-standard-public-facing-services">Identify non-standard public facing services</h4>
<pre><code class="language-plaintext">service_haspublic:t and service_hasip6:f
and not protocol:icmp
and not (port:22 and protocol:ssh)
and not (port:80 and protocol:http)
and not (port:179)
and not (port:443 and (protocol:http or protocol:tls))
and not (port:500 and protocol:ike)
and not (port:5061 and protocol:tls)
</code></pre>
<h4 id="identify-insecure-public-facing-services">Identify insecure public facing services</h4>
<pre><code class="language-plaintext">has_public:t and (protocol:telnet or protocol:ftp or protocol:tftp)
</code></pre>
<h4 id="identify-insecure-public-facing-web-services">Identify insecure public facing web services</h4>
<pre><code class="language-plaintext">has_public:t and protocol:http and not protocol:tls
</code></pre>
<h4 id="identify-non-standard-public-facing-web-services">Identify non-standard public facing web services</h4>
<pre><code class="language-plaintext">service_haspublic:t and protocol:http and not port:80 and not port:443
</code></pre>
<h4 id="high-outlier-score-with-public-facing-ip">High outlier score with public facing IP</h4>
<pre><code class="language-plaintext">outlier:&gt;2 has_public_v4:t
</code></pre>
<h4 id="high-risk-score-with-public-facing-ip">High risk score with public facing IP</h4>
<pre><code class="language-plaintext">risk_rank:&gt;2 has_public_v4:t
</code></pre>
<h4 id="see-more-examplessearch-query-examplesmdmisconfigurations"><a href="/docs/search-query-examples/#misconfigurations">See more examples</a></h4>
<h3 id="alerting-queries-insecure-services">Insecure services</h3>
<h4 id="database-or-secrets-manager-that-does-not-require-authentication">Database or secrets manager that does not require authentication</h4>
<pre><code class="language-plaintext">(_asset.protocol:redis AND protocol:redis AND has:redis.redisVersion)
OR (_asset.protocol:etcd2 protocol:etcd2 etcd2.access:allowed)
OR (_asset.protocol:zookeeper AND protocol:zookeeper AND zk.access:allowed)
OR (_asset.protocol:mongodb AND protocol:mongodb AND mongodb.auth:open)
OR (_asset.protocol:consul protocol:consul has:consul.config.datacenter)
</code></pre>
<h4 id="vulnerable-application-printerlogic-web-service">Vulnerable Application: PrinterLogic web service</h4>
<pre><code class="language-plaintext">_asset.protocol:http protocol:http (html.title:=&#34;Printer%Logic&#34; OR favicon.ico.image.md5:=ab2fc8886bfbf3e986f8015539d29736 OR favicon.ico.image.md5:=95825f2984a2f708205212d05444938e)
</code></pre>
<h4 id="unpatched-application-android-debug-bridge">Unpatched Application: Android debug bridge</h4>
<pre><code class="language-plaintext">_asset.protocol:adb AND protocol:adb AND has:adb.features
</code></pre>
<h4 id="unpatched-application-hid-vertxedge-controllers-vulnerable-to-command-blink-on-command-execution">Unpatched Application: HID VertX/Edge controllers vulnerable to command_blink_on command execution</h4>
<pre><code class="language-plaintext">_asset.protocol:hiddiscoveryd protocol:hiddiscoveryd has:hiddiscoveryd.unpatchedVertXploit
</code></pre>
<h4 id="vulnerable-hardware-accellion-legacy-file-transfer-appliances">Vulnerable Hardware: Accellion legacy file transfer appliances</h4>
<pre><code class="language-plaintext">products:apache AND (
 favicon.ico.image.md5:=9423d9e9ce004c29dd5bc622f0112123 OR
 http.head.setCookie:sfcurl=deleted OR
 http.head.location:/wmLogin OR
 last.http.head.location:/wmLogin
 )
</code></pre>
<h4 id="more-examplessearch-query-examplesmdweak-configurations"><a href="/docs/search-query-examples/#weak-configurations">More examples</a></h4>
<h2 id="alerting-queries-sample-templates">Sample alert templates</h2>
<p><a href="/docs/creating-alert-templates/">Alert templates</a> can help you customize and format alerts triggered from rules you have set up. Here are three common alert templates you can use to get started with raw JSON, Slack, and Microsoft Teams payloads.</p>
<h3 id="asset-service-or-wireless-query-alert-to-siem-or-soar-using-json">Asset, service, or wireless query alert to SIEM or SOAR using JSON</h3>
<p>One-liner for use in the template:</p>
<pre><code class="language-plaintext">{&#34;organization&#34;:{&#34;name&#34;:&#34;{{organization.name}}&#34;,&#34;id&#34;:&#34;{{organization.id}}&#34;},&#34;site&#34;:{&#34;name&#34;:&#34;{{site.name}}&#34;,&#34;id&#34;:&#34;{{site.id}}&#34;},&#34;rule&#34;:{&#34;action&#34;:&#34;{{rule.action}}&#34;,&#34;created_at&#34;:&#34;{{rule.created_at}}&#34;,&#34;created_by&#34;:&#34;{{rule.created_by}}&#34;,&#34;event&#34;:&#34;{{rule.event}}&#34;,&#34;id&#34;:&#34;{{rule.id}}&#34;,&#34;name&#34;:&#34;{{rule.name}}&#34;,&#34;updated_at&#34;:&#34;{{rule.updated_at}}&#34;},&#34;search&#34;:{&#34;url&#34;:&#34;{{search.url}}&#34;,&#34;found&#34;:&#34;{{search.found}}&#34;,&#34;comparator&#34;:&#34;{{search.comparator}}&#34;,&#34;value&#34;:&#34;{{search.value}}&#34;}}
</code></pre>
<p>Human readable version for review:</p>
<pre><code class="language-json">{
  &#34;organization&#34;: {
    &#34;name&#34;: &#34;{{organization.name}}&#34;,
    &#34;id&#34;: &#34;{{organization.id}}&#34;
  },
  &#34;site&#34;: {
    &#34;name&#34;: &#34;{{site.name}}&#34;,
    &#34;id&#34;: &#34;{{site.id}}&#34;
  },
  &#34;rule&#34;: {
    &#34;action&#34;: &#34;{{rule.action}}&#34;,
    &#34;created_at&#34;: &#34;{{rule.created_at}}&#34;,
    &#34;created_by&#34;: &#34;{{rule.created_by}}&#34;,
    &#34;event&#34;: &#34;{{rule.event}}&#34;,
    &#34;id&#34;: &#34;{{rule.id}}&#34;,
    &#34;name&#34;: &#34;{{rule.name}}&#34;,
    &#34;updated_at&#34;: &#34;{{rule.updated_at}}&#34;
  },
  &#34;search&#34;: {
    &#34;url&#34;: &#34;{{search.url}}&#34;,
    &#34;found&#34;: &#34;{{search.found}}&#34;,
    &#34;comparator&#34;: &#34;{{search.comparator}}&#34;,
    &#34;value&#34;: &#34;{{search.value}}&#34;
  }
}
</code></pre>
<h3 id="alerting-playbook-slack">Asset, service, or wireless query alert to Slack</h3>
<p>One-liner for use in the template:</p>
<pre><code class="language-plaintext">{&#34;blocks&#34;:[{&#34;type&#34;:&#34;section&#34;,&#34;text&#34;:{&#34;type&#34;:&#34;mrkdwn&#34;,&#34;text&#34;:&#34;:red_circle: *runZero Alert* - {{rule.name}}&#34;}},{&#34;type&#34;:&#34;divider&#34;},{&#34;type&#34;:&#34;section&#34;,&#34;text&#34;:{&#34;type&#34;:&#34;mrkdwn&#34;,&#34;text&#34;:&#34;*Rule information*\n\n_Name_: {{rule.name}}\n_Type_: {{rule.event}}\n_Link_: https://console.runzero.com/alerts/rule/{{rule.id}}&#34;}},{&#34;type&#34;:&#34;section&#34;,&#34;text&#34;:{&#34;type&#34;:&#34;mrkdwn&#34;,&#34;text&#34;:&#34;*Match information*\n\n_Organization_: {{organization.name}}\n_Site_: {{site.name}}\n_Match count_: {{search.found}}\n_Search_: {{search.value}}\n_Link_: https://console.runzero.com/alerts/rule/{{search.url}}&#34;}}]}
</code></pre>
<p>Human readable version for review:</p>
<pre><code class="language-json">{
  &#34;blocks&#34;: [
    {
      &#34;type&#34;: &#34;section&#34;,
      &#34;text&#34;: {
        &#34;type&#34;: &#34;mrkdwn&#34;,
        &#34;text&#34;: &#34;:red_circle: *runZero Alert* - {{rule.name}}&#34;
      }
    },
    {
      &#34;type&#34;: &#34;divider&#34;
    },
    {
      &#34;type&#34;: &#34;section&#34;,
      &#34;text&#34;: {
        &#34;type&#34;: &#34;mrkdwn&#34;,
        &#34;text&#34;: &#34;*Rule information*\n\n_Name_: {{rule.name}}\n_Type_: {{rule.event}}\n_Link_: https://console.runzero.com/alerts/rule/{{rule.id}}&#34;
      }
    },
    {
      &#34;type&#34;: &#34;section&#34;,
      &#34;text&#34;: {
        &#34;type&#34;: &#34;mrkdwn&#34;,
        &#34;text&#34;: &#34;*Match information*\n\n_Organization_: {{organization.name}}\n_Site_: {{site.name}}\n_Match count_: {{search.found}}\n_Search_: {{search.value}}\n_Link_: https://console.runzero.com/alerts/rule/{{search.url}}&#34;
      }
    }
  ]
}
</code></pre>
<h3 id="alerting-playbook-teams">Asset, service, or wireless query alert to Microsoft Teams</h3>
<p>One-liner for use in the template:</p>
<pre><code class="language-plaintext">{&#34;type&#34;:&#34;message&#34;,&#34;attachments&#34;:[{&#34;contentType&#34;:&#34;application/vnd.microsoft.card.adaptive&#34;,&#34;contentUrl&#34;:null,&#34;content&#34;:{&#34;$schema&#34;:&#34;http://adaptivecards.io/schemas/adaptive-card.json&#34;,&#34;type&#34;:&#34;AdaptiveCard&#34;,&#34;version&#34;:&#34;1.5&#34;,&#34;body&#34;:[{&#34;type&#34;:&#34;TextBlock&#34;,&#34;text&#34;:&#34;runZero Alert-{{rule.name}}&#34;},{&#34;type&#34;:&#34;TextBlock&#34;,&#34;text&#34;:&#34;**Rule information**\n\n_Name_: {{rule.name}}\n\n_Type_: {{rule.event}}\n\n_Link_: [Rule](https://console.runzero.com/alerts/rule/{{rule.id}})&#34;,&#34;wrap&#34;:true},{&#34;type&#34;:&#34;TextBlock&#34;,&#34;text&#34;:&#34;**Match information**\n\n_Organization_: {{organization.name}}\n\n_Site_: {{site.name}}\n\n_Match count_:{{search.found}}\n\n_Search_: {{search.value}}\n\n_Link_: [Search](https://console.runzero.com/alerts/rule/{{search.url}})&#34;,&#34;wrap&#34;:true,&#34;spacing&#34;:&#34;Medium&#34;}]}}]}
</code></pre>
<p>Human readable version for review:</p>
<pre><code class="language-json">{
  &#34;type&#34;: &#34;message&#34;,
  &#34;attachments&#34;: [
    {
      &#34;contentType&#34;: &#34;application/vnd.microsoft.card.adaptive&#34;,
      &#34;contentUrl&#34;: null,
      &#34;content&#34;: {
        &#34;$schema&#34;: &#34;http://adaptivecards.io/schemas/adaptive-card.json&#34;,
        &#34;type&#34;: &#34;AdaptiveCard&#34;,
        &#34;version&#34;: &#34;1.5&#34;,
        &#34;body&#34;: [
          {
            &#34;type&#34;: &#34;TextBlock&#34;,
            &#34;text&#34;: &#34;runZero Alert - {{rule.name}}&#34;
          },
          {
            &#34;type&#34;: &#34;TextBlock&#34;,
            &#34;text&#34;: &#34;**Rule information**\n\n_Name_: {{rule.name}}\n\n_Type_: {{rule.event}}\n\n_Link_: [Rule](https://console.runzero.com/alerts/rule/{{rule.id}})&#34;,
            &#34;wrap&#34;: true
          },
          {
            &#34;type&#34;: &#34;TextBlock&#34;,
            &#34;text&#34;: &#34;**Match information**\n\n_Organization_: {{organization.name}}\n\n_Site_: {{site.name}}\n\n_Match count_: {{search.found}}\n\n_Search_: {{search.value}}\n\n_Link_: [Search](https://console.runzero.com/alerts/rule/{{search.url}})&#34;,
            &#34;wrap&#34;: true,
            &#34;spacing&#34;: &#34;Medium&#34;
          }
        ]
      }
    }
  ]
}
</code></pre>
<h2 id="queries-demo">Outcome demo</h2>
<p>This video is a short demo of what the outcome of alerting on runZero query results may look like.</p>
<iframe src="https://www.loom.com/embed/49415b6d5eba4502a696071bbcf5681d" title="Alerting on runZero Queries Demo" allowfullscreen=""></iframe>
<h2 id="queries-help">Getting help</h2>
<p>If you need assistance in building out this process, you can <a href="https://scheduler.zoom.us/d/z8gaq_36/runzero-customer-success-engineer">book a session with a runZero Customer Success Engineer</a> to discuss further.</p>
