Automating MISP with PyMISP

Script event creation, tagging, publishing, sightings and enrichment in MISP with PyMISP, using scoped keys and a library version that matches your server.

On this page

Automating MISP with PyMISP: when scripts replace manual analyst work

PyMISP is the Python library bundled with MISP for calling its REST API, and teams need it when indicators already exist in internal tools and someone is copying them into MISP by hand. Typical sources include ticketing systems, EDR consoles, mail gateways and incident records. For an illustrative case, a phishing ticket holds a sender domain and two file hashes that an analyst re-types into an event each week. A short script that reads the ticket export and writes the same attributes to MISP removes that step. MISP describes its API as OpenAPI-described, so the endpoints a script calls can be checked against the server's own definitions before anything is automated. The MISP features page summarizes the API and the bundled library.

The common jobs are creating events and objects from tool data, attaching tags from taxonomies and galaxies, publishing events, and adding sightings when a tool sees an indicator in the environment. Each job sets fields that change what other organizations receive, so the script needs deliberate values for distribution, to_ids, published and the tag set rather than inherited defaults. Create a dedicated API key for each script with the narrowest role that allows the call, and record which key wrote each event. Confirm that the PyMISP version installed on the automation host matches the MISP server version, because method names and object handling change between releases. The MISP GitHub repository is the place to check the library and server code together.

Scripts stop being the right tool when a step needs analyst judgment, such as deciding whether an event should leave the organization or which community should receive it. They also stop fitting when volume grows beyond what one process can retry safely, or when a workflow needs approvals, branching and a visible run history. At that point the team should decide who owns the script, how failed writes are retried without duplicating events, and where logs are kept. Ask whoever will operate the automation to confirm those answers in writing before the first scheduled run. Those ownership questions matter more than the script's first version, because the cost of an unattended publish error falls on every organization that receives the event.

Which MISP jobs PyMISP scripts well

Most PyMISP work falls into a few repeatable jobs, and each one depends on the same handful of fields: distribution, to_ids, categories and tags. The cards below cover what each job takes in, what the script must set, and where it usually goes wrong, so you can scope the scripts before anyone writes them.

Creating events from internal tools

Ticketing systems, EDR consoles and mail parsers often hold the first sighting of an incident. A script that turns those records into MISP events should set the event info, the distribution level and the analysis status explicitly rather than accepting server defaults. The main risk is events published wider than the source warrants, because a default distribution can share internal hostnames or user names with partners. Check the distribution value in a test event before the script runs on live data.

MISP features

Attaching attributes and objects

Indicators such as IP addresses, domains and file hashes are added as attributes, while groups of related fields, such as a phishing mail with sender, subject and URL, fit better as objects. The script must set the category and type for each value, and set to_ids only for values that a sensor should act on. The usual failure is marking every extracted value as to_ids, which floods detection exports with context-only data and triggers correlation noise.

Applying tags and galaxies

Tags and galaxy clusters are what make later searches and filters useful, so a script that tags events from a rule set needs a fixed, agreed vocabulary. Confirm that the tag names exist on the server and that taxonomy tags follow the namespace format your team already uses. The risk is inconsistent tagging across scripts, where one tool writes a label that another tool does not search for, so the same campaign ends up split across several tag names.

Publishing events

Publishing is the step that makes an event visible to sync partners and feeds, so it deserves its own control in the script. Publish only after the distribution, to_ids and tag checks have passed, and log the event identifier and the user key that performed the action. The main risk is a script that publishes on creation, which sends unreviewed data to every connected instance. Keep an unpublished review path for new automation until its output has been checked for several runs.

Adding sightings

Sightings record that an indicator was observed in your own environment, which is useful feedback for analysts and for scoring. A sightings script typically takes matches from a SIEM, EDR or DNS log export and posts them against existing attribute identifiers or values. The risk is recording sightings from a broad search that matches shared or benign values, which then skews the signal. Confirm which source the sightings come from and restrict the script to attributes already reviewed by analysts.

Fetching data for enrichment

Enrichment scripts read from MISP to annotate alerts, tickets or case records with known context. They should use a read-only key scoped to the purpose, query only the fields they need and avoid pulling full events when an attribute search is enough. The usual failure is a script that runs with an administrator key, so a compromised enrichment host can write or delete intelligence. Ask your MISP administrator which role and key scope the script will use before it is deployed.

Options for running PyMISP jobs and where each fits

A one-off script run from an analyst's own machine suits exploratory work, such as testing a query, pulling a set of events for review or pushing a small batch of indicators after an investigation. It needs a Python environment with PyMISP installed, a network path to the MISP instance and a key tied to the analyst's own account. Because the script depends on a person running it, nothing runs on a schedule and nothing is logged centrally unless the analyst adds that.

  • Key handling: Use a personal API key with the narrowest role the task needs, and keep it out of shell history and shared notes. Store it in an environment variable or a local secrets tool, not in the script file.
  • Logging: Write the script's output and the event identifiers it touched to a local file, and record the run in the ticket or case that prompted it.
  • Version drift: Analyst machines are updated at different times, so pin the PyMISP version in a requirements file and match it to the server version.
  • Scope creep: Scripts that start on a laptop often end up in production use. Set a rule that anything repeated moves to the server option.
  • Network and certificates: Confirm the workstation can reach the MISP web address from its network segment, and whether the MISP certificate chains to a CA the workstation trusts.

Confirm with your security team whether analyst workstations may hold any MISP key at all, and how those keys are revoked when a person changes role.

How to set up a PyMISP script against your MISP instance

This sequence takes a team from an unknown MISP server to a verified, least-privilege PyMISP connection that can create test data safely. Each step ends with a check, so the script is only trusted once the server, client and permissions agree.

  1. Confirm the MISP server version

    The administrator of the MISP instance checks the running version in the web interface under the administration area, or with the server's own version information, and records it alongside the instance name and environment. Compare it against the current recommended line on the MISP download page and the release notes on the MISP GitHub releases page, since the project recommends MISP 2.5 for new deployments and advises against new 2.4 instances. Done when the version string is written down and you know whether the instance is on a supported line. If the version is older than you expect, confirm the upgrade path with your administrator before writing any code.

  2. Install a matching PyMISP in a virtual environment

    The developer creates a Python virtual environment on the workstation or automation host and installs the PyMISP release that matches the server version line, pinning that version in a requirements file. Keeping the library in an isolated environment prevents system packages from drifting and makes the pin easy to review later. Check the installed version with pip and confirm the import works with a short Python command that prints the version. Done when the pinned version is recorded in the requirements file and the import succeeds in the virtual environment.

  3. Create a dedicated automation user and key

    A MISP administrator creates a separate user account for the script, assigns it to an organization that the script actually needs, and selects the narrowest role that permits the planned task. Generate an API key for that account only, and avoid reusing an analyst's personal key or an administrator account. Confirm in the user list that the account has the expected role and organization, and that no unneeded permissions such as publishing or user management are enabled. Done when the account exists with a documented role and a single key tied to it.

  4. Store the key outside source code

    The developer places the MISP URL and API key in an environment variable or a secrets store that the script reads at runtime, rather than in the script file, a configuration file committed to version control or shell history. Restrict file permissions on any local env file so only the service account can read it, and add that file pattern to the repository ignore list. Verify by searching the repository for the key string and confirming that no match exists. Done when the search returns nothing and the script starts by reading its credentials from the environment.

  5. Make a first read-only call

    The developer runs a single read-only request, such as fetching the server version or a small set of existing events, using the PyMISP client configured with the stored credentials and certificate verification enabled. Confirm the response contains the expected data and that the request is logged on the MISP side under the automation account. If the call fails, check the URL, the key, the TLS trust chain and the account's organization before changing code. Done when the read succeeds and the server log shows the call from the automation user.

  6. Create a test event on a non-production instance

    On a non-production MISP instance or a clearly marked test organization, the developer creates an event with a title that identifies it as a test, adds one or two attributes, and leaves the event unpublished. Using a non-production target prevents test indicators from reaching sharing partners through synchronization. Confirm that the event number returned by the script matches what the interface shows. Done when the event exists, has the expected attributes, and the script's output matches the record in the UI.

  7. Verify in the UI before enabling publishing

    A MISP user with analyst access opens the test event in the web interface and checks the title, distribution level, tags, attribute types, categories and to_ids flags against what the script intended. Confirm the event is not published and that synchronization has not picked it up. Only after these checks pass should the team add a publish step, and then only with a documented reviewer and a rollback plan for deleting or correcting events. Done when the reviewer signs off on the test record and the publish step is a separate, reviewed change.

Keeping PyMISP matched to the MISP server version

Treat the PyMISP library and the MISP server as two moving parts that must be kept in step. Both change on their own schedules, and a script that worked against one server release can fail quietly against the next. The server line you run determines which API behaviour your scripts should expect. The project recommends MISP 2.5 for new deployments and has moved MISP 2.4 to security fixes only, so confirm which line your instance is on before you write or pin anything. Record the exact server version in your automation repository next to the PyMISP version it was tested with.

Pin the PyMISP version in your requirements file or lock file so that a routine dependency update cannot change behaviour without a deliberate decision. Then track server upgrades as change events in their own right. Before upgrading either side, read the project's release notes, which list changes to the API, database migrations and packaging. The MISP GitHub releases page is the place to confirm what changed in a given release. Ask whether any release in the path from your current version to the target version changes an API field, a filter or an authentication behaviour that your scripts use.

After each server or library upgrade, rerun the scripts against a staging instance before they touch production. Use a fixed set of test cases: create an event with an object, add a tag, publish, add a sighting and run a read-only search with your key. Compare the returned fields with the expected output and keep the results as evidence for change review. If a check fails, pin the previous library version until the script is fixed. Confirm with your platform owner who is responsible for this retest and how long a failed script can stay in use.

Scoping API keys and protecting scripts

A PyMISP script runs with whatever permissions its API key carries, so key design is the main access control for automation. The cards below cover how to split keys by job, keep the publishing permission out of scripts that do not need it, and keep automated events inside the intended audience.

Read-only keys for enrichment

Enrichment scripts that look up indicators in MISP only need to search and read. Give them a key tied to a role with read permissions and no ability to create or modify events, attributes or tags. Ask your MISP administrator to confirm which permission flags the default read-only role includes in your version, because role definitions change between releases and a custom role may grant more than its name suggests.

One key per script

Issue a separate API key for each script or integration, named after its job, such as an import job or a sighting job. When one key is compromised or a script is retired, you can revoke that key without breaking unrelated automation. Shared keys make it impossible to tell from the audit trail which process made a change.

Rotating and revoking keys

Set a rotation schedule for every automation key and record the owner of each key in your inventory. Rotation should be rehearsed on a non-production instance first, since a script that fails silently after a key change can leave feeds or imports stale. Confirm with your administrator how key expiry and disablement are handled in your MISP version.

Keeping keys out of code

Never hardcode API keys in PyMISP scripts, repositories or cron files. Load the key from a secrets manager or from a file readable only by the service account that runs the job. Check version control history as well as current code, because a key committed once remains exposed even after it is deleted.

Publishing as a high-impact permission

Publishing makes an event visible to sync partners and communities, so it is the permission with the widest effect. Keep the publish permission off keys used by enrichment, tagging or import scripts unless a reviewed step needs it. Where a script must publish, have it act only on events it created and only after a human or validation check, and confirm how your version gates this permission.

Logging and auditing script actions

Make sure the MISP audit log records which user or key created, edited, published and deleted each object, and forward those entries to your central log platform. Review script activity for unexpected publishes, mass deletions and tag changes. Confirm the log retention and fields your version records, since the defaults may not show the API key used for each request.

Distribution and sharing group defaults

Scripts that create events should set distribution explicitly rather than inherit a permissive default. Use your own organization-only or a closed sharing group for internal tool output, and reserve community distribution for intelligence you have reviewed. Set the same defaults in the script and check that the instance default matches, so a missing parameter does not push internal events to partners.

Questions teams ask before scripting MISP

Can an internal team script MISP automation on its own?

Yes, if one or two engineers already write Python, can read the MISP API documentation and have time to maintain the code after it goes live. PyMISP is the bundled Python library for the MISP REST API, so the core work is familiar: authenticate with an API key, create events and attributes, attach objects, tag and publish. The harder part is not the first script but the ongoing ownership. Source systems change their field names, MISP upgrades can change behavior, and a script that runs unattended needs logging, retries and alerting. Ask whether someone will own the script for its full life, not only the build. If that person is not clear yet, a partner can build the first version and document it so your team can take it over.

What makes a PyMISP automation project take more effort?

Effort follows four drivers. The first is the number of source systems, since each one needs its own extraction, authentication and error handling. The second is data quality: indicators that arrive with inconsistent formats, missing types or unclear confidence need cleaning before they become attributes with the right category and to_ids setting. The third is mapping to MISP object templates, where you decide which fields go into which object and which fields stay as plain attributes. The fourth is testing, which covers duplicate handling, correlation noise and how events look to recipients. Each driver rises with the number of distinct data shapes you ingest. Ask any quote to list the sources, the object templates in scope and the test cases it covers.

What does the work need from our team before it starts?

Three things should be ready before any code is written. First, a test instance of MISP, separate from production, so imports, tagging and publishing can be tried without sending anything to sharing partners. Second, a dedicated service account in MISP with an API key scoped to the jobs it runs, following your key management rules. Third, a named owner for each source system who can explain the export format, confirm field meanings and approve changes. Without the owners, mapping decisions get guessed, and the automation will publish data that nobody on your side can vouch for. Ask the provider to confirm in writing which of these they expect you to supply.

How long does a PyMISP automation take to deliver?

The duration depends on scope, and no single figure applies across organizations. The main variables are the number of source systems, the data quality issues found during discovery, how many object templates need mapping and how much testing your change process requires. A single internal tool feeding one event type is a very different task from a set of jobs covering several sources with approvals before publishing. Ask for a plan that lists phases, what each phase delivers and which decisions your team must make, so timing risks are visible early. Fixed-scope engagements agree scope, deliverables and timelines in writing before work starts.

What should a partner quote for PyMISP automation include?

A useful quote lists the scope in writing: each source system, the MISP events and objects produced, the tagging and publishing rules, and the sightings or read-only jobs included. It should separate one-time build work, such as discovery, mapping, scripting and testing, from recurring work, such as upgrades to match new MISP and PyMISP versions, monitoring and support. Ask what happens when MISP changes version, who runs the test instance, what documentation and handover are delivered, and what the retest process looks like. Also ask which costs are yours, such as the test instance, hosting and staff time for owner reviews. DeployOpen does not publish a price list, and a quote follows from the written scope.

How do we keep PyMISP matched to the MISP server version?

Pin the PyMISP version in your deployment and check it against the MISP server version each time either one changes. MISP 2.5 is the recommended line for new deployments, and MISP 2.4 is end of life with security fixes only, so scripts should target the 2.5 line. Use a test instance to run your jobs after every MISP upgrade, including the 2.5.47 release that introduced a new database migration system with PostgreSQL support. Keep the release notes in your change log and confirm that the API calls your scripts use still behave the same. Ask your provider how version checks are built into the handover.

When should we hire help instead of extending our scripts?

Hire help when the scripts start to carry decisions that need review, such as which indicators are published to partners, or when a second team depends on the automation. Other signals include repeated failures from changing source formats, no one on staff who can explain the mapping, sharing rules that need legal or sector review, or a timeline that your team cannot absorb alongside its normal work. Extending scripts works well for a single, stable source with a clear owner. A partner is useful for designing the object mapping, testing it against real exports, documenting it and handing it over, and for ongoing testing or support through a retainer.

Limits to confirm in your environment

PyMISP scripts depend on limits, object templates and sharing behaviour that belong to your MISP server and your sharing setup, not to the library alone. Confirm each item on your own instance before a script goes into a scheduled job or a production workflow.

API rate and size limits

Check how your instance handles bulk requests, large restSearch result sets and high-frequency calls from one API key. Confirm any limits set in your server configuration, any reverse proxy or load balancer timeouts in front of MISP, and the maximum request body size for imports. Run your largest expected pull and push against a staging instance before you schedule it, and record the timing and any truncated or failed responses.

Object templates and fields

Object templates ship with MISP and can be updated, so the template name, version and attribute fields your script expects may differ between servers. Query the templates your instance exposes before you hard-code object names or relations. Check that each attribute type and category your code sets is accepted by the server, and test a create-and-read round trip on every template your internal tool uses.

Export and search output

A restSearch call or export format may return different fields, filtering or includes than your downstream tool expects, depending on the server version and the enabled export modules. Compare a sample output from your instance with the structure your parser reads. Confirm how to_ids, tags, distribution and warninglist handling behave in the returned data before you trust the result as a blocklist input.

Sightings and publishing behaviour

Adding a sighting or publishing an event can trigger synchronization, notifications and feed updates that depend on your distribution levels and sharing groups. Test these actions on a non-production event and confirm which partner instances receive the change, whether the event is republished, and whether sightings from your script are visible to other organizations. Do not assume that a successful API response means the change left your instance.

PyMISP and server version match

The PyMISP release you pin must support the MISP server release you run, and newer server releases can change API responses or add fields your pinned client does not model. Check the PyMISP release notes against your server version before each upgrade, and keep a test environment that runs both together. Record the pinned versions in your repository so that a server upgrade triggers a compatibility check.

MISP releases

Read-only key scope

Read-only API keys limit what a script can change, but the exact permissions depend on the role attached to the key and the sharing groups the user can see. Confirm that the role blocks writes, that the user sees only the organizations and events the script needs, and that key expiry and rotation are set. Test each key against a write call and a restricted-event search before you give it to an automated job.

How an internal tool sends data to MISP through PyMISP

The flow starts in an internal source system, where a script or scheduled job reads records and calls PyMISP with an API key scoped to that job. PyMISP translates those calls into requests to the MISP REST API, which writes events and attributes into the MISP event store inside the trust boundary. Publishing and any sync to partners sit outside the automated path: a named analyst reviews the content and approves publication before distribution starts. Check the key scope at the API hand-off and confirm the approval gate before anything leaves the instance.

Automated writes stay inside the trust boundary until an analyst approves publishing.

How DeployOpen scopes and delivers MISP automation

DeployOpen approaches PyMISP automation as a scoped piece of work on a MISP instance in infrastructure you control. We agree which jobs get automated, the API keys and server version they depend on, and how results are checked before any script touches production events.

How we scope

  • The written scope lists each job to automate, such as event creation from internal tools, tagging, publishing and sightings.
  • We confirm the MISP server version and the PyMISP release that matches it before any code is planned.
  • The scope names which API keys are needed, which are read-only, and which accounts own each script.

How we build

  • Scripts are written in Python with PyMISP, with object mappings and tags defined from your own taxonomy choices.
  • Each job is tested against a non-production MISP instance before it runs against live events.
  • Publishing and sighting steps are gated so that a failed import cannot push unreviewed data to partners.

How we hand over

  • You receive the scripts, configuration, and a record of which API keys and permissions each job uses.
  • Documentation covers how to rerun each job, how to check its output, and how to roll back a bad import.
  • Handover includes a short walkthrough so your team can change jobs and update PyMISP when the server is upgraded.

How we support

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
  • Ongoing support, PyMISP version matching after server upgrades, and job maintenance are available as a retainer.
  • Quotes follow from the written scope, so ask for the items that drive effort, such as the number of jobs and integrations.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.