API Security

Vadim Markovtsev, Head of Analytics.

API Security

Vadim Markovtsev
Head of Analytics

Accounts and users

How many account types do we have?

3

Account types in our product

How many user types do we have?

5

User types in our product

Authentication

How many authentication ways do we have?

2

Our authentication ways

JWT

APIKeys

How many user access levels do we have?

4

User access levels

Invitations

How many installation links do we have?

3

App links

GitHub links

JIRA links

The key is the account's secret.

Repository access

Attack

curl https://api.athenian.co/v1/metrics/pull_requests --data {
    "account": 1,  # 👍
    "for": [{
        "repositories": [
            "github.com/athenianco/athenian-api",  # 👍
            "github.com/client/repo"  # 😱
    ]}]...}

Defense

Attack

curl https://api.athenian.co/v1/metrics/pull_requests --data {
    "account": 1,  # 👍
    "for": [{
        "repositories": [
            "'; SELECT * FROM github.node_repository WHERE true OR name IN('"  # 😱
            "github.com/athenianco/athenian-api",  # 👍
    ]}]...}

Defense

Use ORM! We use SQLAlchemy Core.

await mdb.fetch_all(
    select([PullRequest])
    .where(and_(
        PullRequest.acc_id == account,
        PullRequest.repository_full_name.in_(repos),
    )))

What does that teach us?

We don't need paid Slack Vadim, we will not search there.

Athenian CEO circa December 2019.

OpenAPI validation

JSON Schema

Swagger vs. OpenAPI

Approaches to OpenAPI

  1. Write code
  2. Generate OpenAPI spec from code
  1. Write OpenAPI spec
  2. Generate code from OpenAPI spec

What we check automatically

Backdoor

Aka "manhole"

Super powers

Thank you, and see you tomorrow