Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
YouTube Security VideosGoogle Cloud Tech: Gemini is coming to your city(24.09.2026 um 15:00 Uhr)
AI & KI NachrichtenGoogle’s latest moonshot to put machine learning in space(24.09.2026 um 15:12 Uhr)
Windows Tipps & SecurityPoll: What's your favorite Surface of 2026?(24.09.2026 um 14:58 Uhr)
Sichere ProgrammierungStreaming Materialized Views for Live Read Models (2026)(24.09.2026 um 15:02 Uhr)
Sichere ProgrammierungA Day Is Not 86400 Seconds: The DST Bug in Your Date Math(24.09.2026 um 15:02 Uhr)
Sichere ProgrammierungSetting up Traefik: reverse proxy with automatic HTTPS(24.09.2026 um 15:02 Uhr)
Sichere ProgrammierungA 200 OK response does not prove a secret leak(24.09.2026 um 15:02 Uhr)
Sichere ProgrammierungHow hot do you like it?(24.09.2026 um 15:05 Uhr)
YouTube Security VideosGoogle Cloud Tech: Gemini is coming to your city(24.09.2026 um 15:00 Uhr)
AI & KI NachrichtenGoogle’s latest moonshot to put machine learning in space(24.09.2026 um 15:12 Uhr)
Windows Tipps & SecurityPoll: What's your favorite Surface of 2026?(24.09.2026 um 14:58 Uhr)
Sichere ProgrammierungStreaming Materialized Views for Live Read Models (2026)(24.09.2026 um 15:02 Uhr)
Sichere ProgrammierungA Day Is Not 86400 Seconds: The DST Bug in Your Date Math(24.09.2026 um 15:02 Uhr)
Sichere ProgrammierungSetting up Traefik: reverse proxy with automatic HTTPS(24.09.2026 um 15:02 Uhr)
Sichere ProgrammierungA 200 OK response does not prove a secret leak(24.09.2026 um 15:02 Uhr)
Sichere ProgrammierungHow hot do you like it?(24.09.2026 um 15:05 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Clean authorization control in serverless functions

In this article, I walk you through some control points to clean up authorization code in your serverless functions. Serverless applications have a lot of benefits. They are easy to deploy and scale. They are also cheap to run. 🤑 However, …

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

In this article, I walk you through some control points to clean up authorization code in your serverless functions.



Serverless applications have a lot of benefits. They are easy to deploy and scale. They are also cheap to run. 🤑 However, they come with a few drawbacks. One of them being authorization hard to get right. On this matter is easy to make mistakes, write poorly maintainable code and introduce vulnerabilities. 😱






🕷️ Access control code can be ugly



In a typical multitenant serverless application on AWS, where Lambda is integrated with API Gateway for each endpoint, you have to write authorization code. This is code that will check whether the user who originated the request is allowed to access data or perform an action.



While in a monolithic application, you can rely on a framework to help you with that, you are on your own with serverless functions.



As your application evolves and becomes more complex, this becomes hard to maintain and check for vulnerabilities.



Hopefully, you can come up with a good access control strategy if you properly structure your code. 🏗️






🤦‍♂️ Naive solution: authorization code in the business logic



Let's consider a simple multitenant application to manage files for organizations. The application has two personas: CEO and user. CEO can access all files within their organization. Users can only access files they have created.



A poorly designed function that handles the request to get a file might look like this:




// POORLY designed function

export const handler = async (event, context) => {
// Check that the user is in the requested organization
// 🐍 authorization with business logic not directly related to the use case
const userId = context.requestContext.authorizer.userId;
const organizationId = event.pathParameters.organizationId;
const user = await getUser(userId);
// 🐍 deny list based authorization
if (!user.organizations.includes(organizationId)) {
return {
statusCode: 403,
};
}

// Retrieve the file
// 🚀 business logic
const fileId = event.pathParameters.id;
const file = await getFile(fileId);

// Deny access if the user is not CEO or the author is not the user
// 🐍 access control happening late
if (event.requestContext.authorizer.role !== 'CEO' && file.authorId !== event.requestContext.authorizer.userId) {
return {
statusCode: 403,
};
}

return {
statusCode: 200,
body: JSON.stringify(file),
};
};









🧅 Share authorization code that all your functions use



In many cases, you will have to write the same authorization code in multiple functions. For example, you might want to check that the user is in the requested organization. You can share this code in a middleware. If you are using AWS Lambda, you can rely on middy.



Using a middleware will separate authorization code from the business logic and make it much easier to read.



Organizing your code in layers helps a lot. You can also enrich the context with the user information in a middleware, for later use in subsequent steps.




// src/middlewares/addUserToContext.ts

export const addUserToContext = async (event, context) => {
const userId = event.requestContext.authorizer.userId;
const user = await getUser(userId);
context.user = user;
};









⏱️ Early check authorization



Denying a rogue access as early as possible is a good practice.



Frameworks like Spring and Nest have decorators that you can use as soon as your function definition.



Find a way to check authorization as early as possible in the function.




// src/handlers/getFile.ts

const getFile = async (event, context) => {
// Check that the user is in the requested organization
if (!context.user.organizations.includes(organizationId)) {
return {
statusCode: 403,
};
}

// If the user is not CEO, add a filter to only retrieve the files created by the user
const filters = {};
if (event.requestContext.authorizer.role !== 'CEO') {
filters.authorId = event.requestContext.authorizer.userId;
}

// Retrieve the file
const fileId = event.pathParameters.id;
const file = await getFile(fileId, filters);

// Deny access if the user is not CEO or the author is not the user
if (file === null) {
return {
statusCode: 404,
};
}

return {
statusCode: 200,
body: JSON.stringify(file),
};
};

export const handler = middy(getFile).use(addUserToContext);






Again, leverage middleware to extract the authorization code from the business logic. ⛏️ See the next section for a full example.






📁 Use file hierarchy to identify shared and specific code



Mind the file hierarchy. You should identify shared and specific code at a glance 👀 Below you can see that every handler might have a specific validateAccess logic, while shared middleware is available higher in the hierarchy.




src/
handlers/
getFile/
getFile.ts
index.ts
validateAccess.ts
middlewares/
addUserToContext/
addUserToContext.ts
index.ts
validateTenancy/
validateTenancy.ts
index.ts






The function now only contains business logic.




// src/handlers/getFile/getFile.ts
export const getFile = async (event, context) => {
// Retrieve the file
const file = await getFile(filters);

if (file === null) {
return {
statusCode: 404,
};
}

return {
statusCode: 200,
body: JSON.stringify(file),
};
};






Middleware can be found at the handler definition level.




// src/handlers/getFile/index.ts
export const handler = middy(getFile).use(addUserToContext).use(validateTenancy).use(validateAccess);






Shared middleware to validate tenancy (user is requesting a resource in their organization).




// src/middlewares/validateTenancy.ts
const validateTenancy = async (event, context) => {
// Check that the user is in the requested organization
if (!context.user.organizations.includes(organizationId)) {
return {
statusCode: 403,
};
}
};






Specific middleware to validate access (user is requesting a resource they have access to).




// src/handlers/getFile/validateAccess.ts
const validateAccess = async (event, context) => {
if (event.requestContext.authorizer.role === 'CEO') {
return;
}

event.filters = {
fileId: event.pathParameters.id,
authorId: event.requestContext.authorizer.userId,
};
};






Pro tip 🚀 prefer allow list based authorization over deny list based authorization. This is a best practice, that will deny access by default.






Useful links



SOC Incident Playbook: Remote Code Execution (RCE) Defense
title: Detect Exploitation - Clean authorization control in serverless functions
id: 9566106b-0af4-4852-a84b-f78a812c9f2c
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-24
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-24"
        description = "YARA Signature for "
    strings:
        $str = "Clean authorization control in" ascii wide
    condition:
        any of them
}
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Clean authorization control in serverles.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Clean authorization control in serverless functions

Thematisch verwandte Begriffe: Clean, authorization, control, serverless · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-97179 | A security vulnerability has been detected in O2OA up to 9.5.3/10.0.2. T…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel TTP ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick