<?xml version="1.0" encoding="utf-8"?>
<!-- name="GENERATOR" content="github.com/mmarkdown/mmark Mmark Markdown Processor - mmark.miek.nl" -->
<rfc version="3" ipr="trust200902" docName="draft-dulaunoy-mispql-00" submissionType="independent" category="info" xml:lang="en" xmlns:xi="http://www.w3.org/2001/XInclude" indexInclude="true">

<front>
<title abbrev="MispQL">MispQL: A Query Language for Cyber Threat Intelligence</title><seriesInfo value="draft-dulaunoy-mispql-00" stream="independent" status="informational" name="Internet-Draft"></seriesInfo>
<author initials="A." surname="Dulaunoy" fullname="Alexandre Dulaunoy"><organization abbrev="CIRCL">Computer Incident Response Center Luxembourg</organization><address><postal><street></street>
</postal><email>alexandre.dulaunoy@circl.lu</email>
</address></author><author initials="A." surname="Iklody" fullname="Andras Iklody"><organization abbrev="CIRCL">Computer Incident Response Center Luxembourg</organization><address><postal><street></street>
</postal><email>andras.iklody@circl.lu</email>
</address></author><date year="2026" month="November" day="26"></date>
<area>Security</area>
<workgroup></workgroup>

<abstract>
<t>MispQL is a read-only, SQL-like query language for cyber threat
intelligence (CTI). This document specifies its text syntax using
Augmented Backus-Naur Form (ABNF), its query semantics, and a JSON
representation for its Boolean filters. A CTI platform can implement
MispQL over its own data model by describing the tables, fields, types,
and operators it supports. A transport binding describes how the Python
MispQL client uses the complex-search interface in MISP 3.0.</t>
</abstract>

</front>

<middle>

<section anchor="introduction"><name>Introduction</name>
<t>CTI platforms store indicators, event reports, analyst annotations, and
other records that analysts need to search across tools. MispQL provides
a common way to express such searches, including Boolean conditions,
projection, sorting, pagination, and counts. The language originated
in the MISP project. Its earlier MISP query format <xref target="MISP-QUERY"></xref>
describes legacy REST filters. This document specifies MispQL text and
composable filter trees as a separate interface.</t>
<t>A <em>table</em> is a named collection of records exposed by a platform. A
<em>schema profile</em> defines the tables and semantics an implementation
exposes to a caller. A <em>binding</em> maps a query or its filter to a
particular execution interface. Implementations can share the language
across different storage engines and transports. A query that names
fields from a particular profile is portable to platforms that expose
the same profile and implement the capabilities the query uses.</t>

<section anchor="conventions-and-terminology"><name>Conventions and Terminology</name>
<t>The key words &quot;MUST&quot;, &quot;MUST NOT&quot;, &quot;REQUIRED&quot;, &quot;SHALL&quot;, &quot;SHALL NOT&quot;,
&quot;SHOULD&quot;, &quot;SHOULD NOT&quot;, &quot;RECOMMENDED&quot;, &quot;NOT RECOMMENDED&quot;, &quot;MAY&quot;, and
&quot;OPTIONAL&quot; in this document are to be interpreted as described in
BCP 14 <xref target="RFC2119"></xref> <xref target="RFC8174"></xref> when, and only when, they appear in
all capitals, as shown here.</t>
</section>
</section>

<section anchor="text-syntax"><name>Text Syntax</name>
<t>This section defines the grammar in ABNF <xref target="RFC5234"></xref>. Quoted ABNF
strings are ASCII case-insensitive. Literal input is UTF-8
<xref target="RFC3629"></xref>. The start rule is <tt>script</tt>. A semicolon separates
statements. Leading, repeated, and trailing semicolons are allowed.
The final statement can end at end of input.</t>

<section anchor="lexical-rules"><name>Lexical Rules</name>
<t>Before applying the statement rules, a lexer MUST use the following
token boundaries to resolve adjacent tokens.</t>

<ul spacing="compact">
<li>A maximal run of ASCII letters, digits, and underscores is one
word. A word beginning with a digit MUST consist entirely of
digits. A lexer MUST NOT split a word to obtain a keyword or
integer. For example, <tt>SELECTid</tt> and <tt>100AND</tt> are single words.</li>
<li><tt>reserved</tt> enumerates the keywords. Those words are recognized
case-insensitively and MUST be quoted with backticks when used
as identifiers. Unquoted identifiers are folded to ASCII
lowercase. Quoted identifiers preserve their spelling and MUST
decode to a nonempty value.</li>
<li>Single and double quotes delimit strings. Backticks delimit
identifiers. Two consecutive copies of the current delimiter
within a quoted token encode one copy of that delimiter.
Backslash is an ordinary character. A lexer MUST consume a
quoted token through its first undoubled closing delimiter.</li>
<li>Outside quotes, <tt>--</tt> starts a comment through the next LF or end
of input. The lexer consumes the longest comparison operator
available, so <tt>&gt;=</tt>, <tt>&lt;=</tt>, <tt>&lt;&gt;</tt>, and <tt>!=</tt> are each a single token.
Optional whitespace and comments occur only at the positions of
<tt>ws</tt>. In particular, a hyphenated name contains no whitespace.</li>
</ul>
</section>

<section anchor="abnf"><name>ABNF</name>
<t>The lexical rules and the ABNF together define syntactic validity.
Schema and clause checks are applied after parsing.</t>

<sourcecode type="abnf"><![CDATA[script          = ws *(";" ws)
                  [statement *(ws 1*(";" ws) statement)
                   ws *(";" ws)] [eof-comment]

statement       = select-stmt / show-tables / describe-stmt
                  / session-stmt
select-stmt     = "SELECT" ws projection ws "FROM" ws name
                  [ws where-clause] [ws order-clause]
                  [ws limit-clause] [ws offset-clause]
                  [ws format-clause]

projection      = "*" / "COUNT" ws "(" ws "*" ws ")"
                  / field *(ws "," ws field)
where-clause    = "WHERE" ws expression
order-clause    = "ORDER" ws "BY" ws order-item
                  *(ws "," ws order-item)
order-item      = field [ws ("ASC" / "DESC")]
limit-clause    = "LIMIT" ws uint
offset-clause   = "OFFSET" ws uint
format-clause   = "FORMAT" ws format-name

expression      = and-expr *(ws "OR" ws and-expr)
and-expr        = not-expr *(ws "AND" ws not-expr)
not-expr        = "NOT" ws not-expr / "(" ws expression ws ")"
                  / predicate
predicate       = field ws (comparison ws literal
                  / [ "NOT" ws ] ("IN" ws literal-list
                  / "LIKE" ws string))
comparison      = "<=" / ">=" / "<>" / "!=" / "=" / "<" / ">"
literal-list    = "(" ws literal *(ws "," ws literal) ws ")"
literal         = string / integer / "TRUE" / "FALSE"
integer         = ["-" ws] uint
uint            = 1*DIGIT

show-tables     = "SHOW" ws "TABLES"
describe-stmt   = ("DESCRIBE" / "DESC") ws name
session-stmt    = "SHOW" ws "DATABASES"
                  / "USE" ws database-name / "WHOAMI"

field           = name *(ws "." ws name)
name            = bare-name / quoted-name
bare-name       = word-name  ; excluding reserved words
word-name       = (ALPHA / "_") *(ALPHA / DIGIT / "_")
hyphen-tail     = *("-" (word-name / uint))
format-name     = word-name hyphen-tail / quoted-name / string
database-name   = bare-name hyphen-tail / quoted-name

reserved        = "AND" / "ASC" / "BY" / "COUNT" / "DATABASES"
                  / "DESC" / "DESCRIBE" / "FALSE" / "FORMAT"
                  / "FROM" / "IN" / "LIKE" / "LIMIT" / "NOT"
                  / "OFFSET" / "OR" / "ORDER" / "SELECT" / "SHOW"
                  / "TABLES" / "TRUE" / "USE" / "WHERE" / "WHOAMI"

string          = squote *(sq-char / squote squote) squote
                  / DQUOTE *(dq-char / DQUOTE DQUOTE) DQUOTE
quoted-name     = backtick 1*(bt-char / backtick backtick)
                  backtick
squote          = %x27
backtick        = %x60
sq-char         = quoted-ws / %x20-26 / %x28-7E / utf8-non-ascii
dq-char         = quoted-ws / %x20-21 / %x23-7E / utf8-non-ascii
bt-char         = quoted-ws / %x20-5F / %x61-7E / utf8-non-ascii
quoted-ws       = HTAB / CR / LF

ws              = *(SP / HTAB / CR / LF / line-comment)
line-comment    = "--" *comment-char LF
eof-comment     = "--" *comment-char
comment-char    = HTAB / CR / %x20-7E / utf8-non-ascii

utf8-non-ascii  = %xC2-DF tail-byte
                  / %xE0 %xA0-BF tail-byte
                  / %xE1-EC 2tail-byte
                  / %xED %x80-9F tail-byte
                  / %xEE-EF 2tail-byte
                  / %xF0 %x90-BF 2tail-byte
                  / %xF1-F3 3tail-byte
                  / %xF4 %x80-8F 2tail-byte
tail-byte       = %x80-BF
]]>
</sourcecode>
</section>
</section>

<section anchor="query-semantics"><name>Query Semantics</name>

<section anchor="schema-profiles-and-validation"><name>Schema Profiles and Validation</name>
<t>An implementation MUST validate the syntax and all names, value
types, operators, and clause combinations for the selected binding
and schema profile. It MUST reject an invalid or unsupported query as a
whole, without running a version with any condition or clause omitted.</t>
<t>A profile MUST document the exposed tables, filter fields and their
types and permitted operators, projected and sortable fields,
comparison and sort collations, default ordering, and any defaults
or limits on result size. Filter, projection, and sort capabilities
can differ for the same field. A profile MUST also describe any
aliases, how qualification and nested names are resolved, and how a
field drawn from related or multivalued records matches. For example, a
profile might define a related field to match a parent when at least
one visible child satisfies the predicate. Two independent predicates
on related fields do not imply that the same child satisfies both
predicates, unless the profile explicitly defines that behavior.</t>
<t>A field name can be a single identifier or a dotted path. A dot
inside a backtick-quoted identifier is part of that identifier.
A binding that flattens paths MUST resolve the name against the
profile before translating it and reject ambiguous mappings.</t>
<t>An implementation of the portable query language MUST support
row selection, projection, Boolean filters, and counting on at
least one exposed table. Operator support is described per field.
An implementation MUST support discovery through the text commands
or an equivalent programmatic interface. Support for a particular
schema profile, sort field, output format, or session command can
be claimed independently. The MISP binding has profile-specific
restrictions described below.</t>
</section>

<section anchor="filtering-and-types"><name>Filtering and Types</name>
<t><tt>WHERE</tt> selects rows for which the expression is true. Parentheses
group expressions. From highest to lowest precedence, predicates
and parenthesized expressions bind before unary <tt>NOT</tt>, which binds
before <tt>AND</tt>, which binds before <tt>OR</tt>. <tt>AND</tt> requires all operands
to match and <tt>OR</tt> requires at least one. A query without <tt>WHERE</tt>
selects all visible rows subject to the other clauses and limits.</t>
<t><tt>=</tt> tests equality. <tt>!=</tt> and <tt>&lt;&gt;</tt> are equivalent spellings.
<tt>IN</tt> tests equality with any member of a nonempty list. <tt>LIKE</tt>
matches a string using a pattern that contains a nonempty literal
portion and one <tt>%</tt> at the beginning, at the end, or at both ends.
A <tt>%</tt> matches zero or more characters. An internal <tt>%</tt> is invalid
in this pattern. Underscore and backslash are literal characters in
the portable pattern syntax. <tt>!=</tt>, <tt>NOT IN</tt>, and <tt>NOT LIKE</tt> are
the Boolean complements of <tt>=</tt>, <tt>IN</tt>, and <tt>LIKE</tt> respectively in
the portable semantics.</t>
<t>The ordered comparison operators <tt>&lt;</tt>, <tt>&lt;=</tt>, <tt>&gt;</tt>, and <tt>&gt;=</tt> apply
to ordered types declared in the profile. For portable field types
these are integers, timestamps, dates, and datetimes. Strings,
integers, and Booleans are distinct literal types. A numeric string
MUST NOT be silently converted to an integer. Each operand of <tt>IN</tt>
MUST be valid for the declared field type. A literal has no NULL,
floating-point, or implicit field-reference form. In the portable
semantics a missing or null field does not satisfy a positive
predicate. Its negation is true when the positive predicate is false.</t>
<t>A profile that exposes timestamps SHOULD accept integer seconds
since 1970-01-01 00:00:00 UTC. Profiles MAY support relative time
on temporal fields using a quoted unsigned decimal followed by
<tt>d</tt>, <tt>h</tt>, <tt>m</tt>, or <tt>s</tt> for days, hours, minutes, or seconds ago.
A profile that supports relative time MUST specify its clock,
calendar and time zone rules, and permitted units for each temporal
type. It MUST use one reference time per logical query, including
pages that together implement one query. Date and datetime strings
are lexical strings and are checked against the field type after
parsing.</t>
<t>A binding that provides special field or operator semantics MUST
document them as profile-specific behavior. A translator MUST
reject a query if it cannot preserve the requested semantics.</t>
</section>

<section anchor="projection-counting-ordering-and-pagination"><name>Projection, Counting, Ordering, and Pagination</name>
<t><tt>SELECT *</tt> returns the profile's default row representation.
An explicit projection returns the listed fields in the specified
order. <tt>SELECT COUNT(*)</tt> returns one nonnegative integer giving
the number of visible rows that match the filter. It requires a
<tt>WHERE</tt> and MUST NOT contain <tt>ORDER BY</tt>, <tt>LIMIT</tt>, <tt>OFFSET</tt>, or
<tt>FORMAT</tt>. An ordinary row query MUST include <tt>WHERE</tt> or <tt>LIMIT</tt>.</t>
<t><tt>ORDER BY</tt> compares the listed keys in order. The first key that
differs determines the order. <tt>ASC</tt> is the default direction and
<tt>DESC</tt> reverses it. A profile MUST specify where missing and null
sort keys appear. An implementation SHOULD use a stable
tie-breaker for paginated results. <tt>OFFSET</tt> skips a zero-based
number of matching rows in the effective order, and <tt>LIMIT</tt> caps
the remaining results at a positive whole number. <tt>OFFSET</tt>
requires <tt>LIMIT</tt>. Concurrent data changes can affect paging when
the binding provides no snapshot isolation.</t>
<t><tt>FORMAT</tt> requests a representation supported by the binding.
The profile MUST specify any restrictions on combining a format
with projection or pagination. An implementation MUST reject an
unsupported format rather than silently choosing a different one.</t>
</section>

<section anchor="discovery-and-session-commands"><name>Discovery and Session Commands</name>
<t><tt>SHOW TABLES</tt> lists the tables available to the caller.
<tt>DESCRIBE table</tt> (also <tt>DESC table</tt>) describes the table's
schema and query capabilities. A profile SHOULD expose this
information programmatically, including limits where available.
Discovery MUST respect the caller's authorization.</t>
<t><tt>SHOW DATABASES</tt>, <tt>USE</tt>, and <tt>WHOAMI</tt> are optional client
session commands. They list configured connections, select a
configured connection for subsequent statements, or display the
identity associated with the active connection, respectively.
They do not change data or form part of the filter representation.
An implementation without session support MUST reject such a
statement explicitly.</t>
</section>
</section>

<section anchor="json-filter-representation"><name>JSON Filter Representation</name>
<t>A binding MAY exchange the <tt>WHERE</tt> expression as a JSON
<xref target="RFC8259"></xref> tree. This section defines the tree for that binding.
Each node is an object with exactly one member. Duplicate member
names MUST be rejected before evaluating a tree. The names <tt>AND</tt>,
<tt>OR</tt>, and <tt>NOT</tt> are reserved, case-sensitive tree keys.</t>
<table>
<thead>
<tr>
<th>Node</th>
<th>Member value</th>
</tr>
</thead>

<tbody>
<tr>
<td><tt>AND</tt> or <tt>OR</tt></td>
<td>A nonempty array of nodes</td>
</tr>

<tr>
<td><tt>NOT</tt></td>
<td>One node</td>
</tr>

<tr>
<td>A profile-resolved field name</td>
<td>A scalar or a one-member operator object</td>
</tr>
</tbody>
</table><t>A scalar MUST be a JSON string, Boolean, or integer number. JSON
integers in this format use the JSON integer syntax without a
fraction or exponent. Senders SHOULD stay within the interoperable
exact-integer range of JSON when the receiver's precision is
unknown. JSON null is invalid. An unwrapped scalar is shorthand
for equality. Operator object keys are the case-sensitive strings
in the following table.</t>
<table>
<thead>
<tr>
<th>Operator keys</th>
<th>Member value</th>
</tr>
</thead>

<tbody>
<tr>
<td><tt>=</tt>, <tt>!=</tt>, <tt>&lt;</tt>, <tt>&lt;=</tt>, <tt>&gt;</tt>, <tt>&gt;=</tt></td>
<td>A scalar accepted by the field</td>
</tr>

<tr>
<td><tt>IN</tt>, <tt>NOT IN</tt></td>
<td>A nonempty array of scalars accepted by the field</td>
</tr>

<tr>
<td><tt>LIKE</tt>, <tt>NOT LIKE</tt></td>
<td>A pattern string</td>
</tr>
</tbody>
</table><t>A translator MUST preserve the Boolean grouping and literal
types, normalize <tt>&lt;&gt;</tt> to <tt>!=</tt>, and resolve field names using the
profile. It MAY flatten adjacent identical <tt>AND</tt> or <tt>OR</tt> nodes
where grouping has no effect on the profile semantics. Table
selection, projection, paging, sorting, and output representation
remain outside the tree. This document defines no common request
envelope or result serialization for those parameters.</t>
</section>

<section anchor="examples"><name>Examples</name>
<t>These examples use an <tt>attributes</tt> table with integer <tt>id</tt> and
<tt>timestamp</tt> fields and string <tt>type</tt> and <tt>value</tt> fields.
<tt>timestamp</tt> is a UTC epoch timestamp and also accepts relative
time. The table supports sorting by <tt>id</tt> and projecting <tt>id</tt>,
<tt>type</tt>, and <tt>value</tt>. A CTI platform can map those fields to
its native indicator records.</t>

<section anchor="filter-sort-and-page"><name>Filter, Sort, and Page</name>
<t>The following query selects domain and destination-IP attributes
with <tt>id</tt> greater than 50000, orders them by decreasing <tt>id</tt>,
skips ten matches, and returns up to ten rows.</t>

<sourcecode type="sql"><![CDATA[SELECT id, type, value FROM attributes
WHERE (type = 'domain' OR type = 'ip-dst') AND id > 50000
ORDER BY id DESC LIMIT 10 OFFSET 10;
]]>
</sourcecode>
<t>The filter tree for this query is:</t>

<sourcecode type="json"><![CDATA[{
  "AND": [
    {"OR": [{"type": "domain"}, {"type": "ip-dst"}]},
    {"id": {">": 50000}}
  ]
}
]]>
</sourcecode>
<t><tt>type IN ('domain', 'ip-dst')</tt> is equivalent to the parenthesized
disjunction in this profile.</t>
</section>

<section anchor="count-recent-indicators"><name>Count Recent Indicators</name>
<t>This query counts visible domain attributes whose value ends in
<tt>.example.org</tt> and whose timestamp is at least as recent as the
cutoff seven days ago.</t>

<sourcecode type="sql"><![CDATA[SELECT COUNT(*) FROM attributes
WHERE type = 'domain' AND value LIKE '%.example.org'
  AND timestamp >= '7d';
]]>
</sourcecode>
<t>The portable filter tree is:</t>

<sourcecode type="json"><![CDATA[{
  "AND": [
    {"type": "domain"},
    {"value": {"LIKE": "%.example.org"}},
    {"timestamp": {">=": "7d"}}
  ]
}
]]>
</sourcecode>
</section>

<section anchor="discovery-and-quoting"><name>Discovery and Quoting</name>

<sourcecode type="sql"><![CDATA[SHOW TABLES;
DESCRIBE attributes;
-- The literal value contains a single quote.
SELECT id FROM attributes WHERE value = 'analyst''s note' LIMIT 1;
]]>
</sourcecode>
</section>

<section anchor="negation-and-membership"><name>Negation and Membership</name>
<t>The following query selects attributes that are neither a domain
nor a destination IP and have an ID of at least 50000.</t>

<sourcecode type="sql"><![CDATA[SELECT id FROM attributes
WHERE NOT (type IN ('domain', 'ip-dst')) AND id >= 50000;
]]>
</sourcecode>

<sourcecode type="json"><![CDATA[{
  "AND": [
    {"NOT": {"type": {"IN": ["domain", "ip-dst"]}}},
    {"id": {">=": 50000}}
  ]
}
]]>
</sourcecode>
</section>

<section anchor="invalid-queries"><name>Invalid Queries</name>

<ul spacing="compact">
<li><tt>SELECT * FROM attributes WHERE id IN ();</tt> is a syntax error
because <tt>IN</tt> requires at least one operand.</li>
<li><tt>SELECT * FROM attributes WHERE id = '50001';</tt> parses but
fails type validation for an integer field.</li>
<li><tt>SELECT * FROM attributes WHERE id &gt; 50000 OFFSET 10;</tt>
parses but fails validation because <tt>OFFSET</tt> requires <tt>LIMIT</tt>.</li>
<li><tt>SELECT COUNT(*) FROM attributes WHERE id &gt; 50000 LIMIT 1;</tt>
parses but fails validation because a count has no <tt>LIMIT</tt>.</li>
<li><tt>SELECT * FROM attributes WHERE value LIKE 'a%b%';</tt>
parses but fails pattern validation because <tt>%</tt> is internal.</li>
</ul>
</section>
</section>

<section anchor="misp-binding"><name>MISP Binding</name>
<t>The MISP complex-search interface <xref target="MISP-COMPLEX"></xref> accepts the
filter tree in the <tt>query</tt> member of a JSON body sent by HTTP POST
to the selected <tt>restSearch</tt> endpoint. The table determines the
endpoint. For example, <tt>attributes</tt> maps to
<tt>/attributes/restSearch</tt>, while <tt>notes</tt> maps to
<tt>/analyst_data/restSearch/Note</tt>. The corresponding <tt>queryDescribe</tt>
endpoints expose field types, operators, sort capabilities, and
limits. Access to complex queries requires the applicable MISP
permission. MISP applies its access controls and any legacy
filters in conjunction with the supplied query.</t>
<t>For the paging example, the Python client can send the following
body to <tt>/attributes/restSearch</tt>. MISP numbers pages from one.
The client projects the returned rows to the requested columns.</t>

<sourcecode type="json"><![CDATA[{
  "returnFormat": "json",
  "limit": 10,
  "page": 2,
  "order": ["id desc"],
  "query": {
    "AND": [
      {"OR": [{"type": "domain"}, {"type": "ip-dst"}]},
      {"id": {">": 50000}}
    ]
  }
}
]]>
</sourcecode>
<t>For an arbitrary offset the Python client can fetch adjacent pages
and trim parsed rows as necessary. For an export returned verbatim,
it requires the offset to be a multiple of the limit. A count is
read from the body for attributes and from <tt>X-Result-Count</tt> for
events using a one-row metadata request. These transport details
are specific to this binding.</t>
<t>MISP field semantics are defined by the target endpoint. For example,
some related fields on events and objects allow only positive
operators. Negated tag filters can also redact nested results, and
tags have special matching rules. MISP validates pattern and value
forms, including rejecting empty strings on its string fields and
rejecting equality or membership strings that begin or end with
<tt>%</tt>. Datetime interpretation can depend on the table. A client
targeting MISP MUST use its advertised capabilities and binding
rules rather than assuming that syntactic validity implies support.</t>
<t>Some versions of MISP can ignore an unrecognized <tt>query</tt> key.
A client MUST establish support before sending a filter and MUST
treat denied or unavailable discovery as a failure to execute the
filtered query. The Python client checks the response from
<tt>/attributes/queryDescribe</tt> before using the complex-search
interface, scoped to its active connection.</t>
</section>

<section anchor="implementation-status"><name>Implementation Status</name>
<t>The open-source MispQL CLI and Python library <xref target="MISPQL-PY"></xref>
implement the text lexer, parser, and compiler. The compiler
produces request plans for the MISP binding. The CLI executes the
requests, while the library also supports callers that handle
transport themselves.</t>
<t>The MISP 3.0 development branch <xref target="MISP-3"></xref> implements the
server side of that binding. Its complex-query engine validates
the JSON tree and evaluates it through MISP's REST search
endpoints <xref target="MISP-COMPLEX"></xref>. The server interface consumes
structured filters. The Python client provides the text syntax
in front of it. These are implementations of complementary
parts of the binding. The proposed portable profile rules in
this draft can be used by other CTI platforms.</t>
</section>

<section anchor="security-considerations"><name>Security Considerations</name>
<t>MispQL input and all decoded field names and values are untrusted.
A service MUST resolve field names and operators against an
allowlist and use parameterized values or a structured backend
query API. It MUST NOT treat MispQL source or decoded strings as
backend SQL or command text.</t>
<t>Authorization MUST apply before filtering, projection, sorting,
counting, paging, and other observable operations. An
implementation MUST also enforce authorization for related
records consulted by predicates. A service MUST NOT expose
restricted data through counts, sort keys, cursors, or discovery.
A client MUST NOT retry a denied or unsupported filter as an
unfiltered search.</t>
<t>Implementations SHOULD bound input size, tree depth, number of
nodes, operand lengths, list sizes, page size, and execution
time. Large disjunctions, substring searches, negation, and
queries over related records can be costly even when they return
few results. Implementations SHOULD apply limits before backend
execution where possible and return a clear error when execution
cannot finish within the applicable limits.</t>
<t>Queries, errors, and responses may contain sensitive intelligence.
Remote bindings SHOULD use authenticated and encrypted transport.
Implementations SHOULD avoid exposing credentials or sensitive
literals in diagnostic messages and logs. Clients that support
multiple connections MUST scope credentials to their intended
service and SHOULD make the active connection apparent before
executing a query.</t>
</section>

<section anchor="iana-considerations"><name>IANA Considerations</name>
<t>This document requests no IANA actions.</t>
</section>

</middle>

<back>
<references><name>References</name>
<references><name>Normative References</name>
<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.3629.xml"/>
<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5234.xml"/>
<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8259.xml"/>
</references>
<references><name>Informative References</name>
<reference anchor="MISP-3" target="https://github.com/MISP/MISP/tree/3.0_wip">
  <front>
    <title>MISP 3.0 development branch</title>
    <author>
      <organization>MISP Project</organization>
    </author>
    <date></date>
  </front>
</reference>
<reference anchor="MISP-COMPLEX" target="https://github.com/MISP/MISP/blob/3.0_wip/docs/restsearch-complex-query.md">
  <front>
    <title>Complex queries in restSearch</title>
    <author>
      <organization>MISP Project</organization>
    </author>
    <date></date>
  </front>
</reference>
<reference anchor="MISP-QUERY" target="https://github.com/MISP/misp-rfc/blob/main/misp-query-format/raw.md">
  <front>
    <title>MISP query format</title>
    <author fullname="Alexandre Dulaunoy" initials="A." surname="Dulaunoy"></author>
    <author fullname="Andras Iklody" initials="A." surname="Iklody"></author>
    <date year="2018" month="October"></date>
  </front>
</reference>
<reference anchor="MISPQL-PY" target="https://github.com/MISP/MispQL">
  <front>
    <title>MispQL CLI and Python library</title>
    <author>
      <organization>MISP Project</organization>
    </author>
    <date></date>
  </front>
</reference>
</references>
</references>

</back>

</rfc>
