Zum Hauptinhalt springen
LIVE
CVSS 6.9CVE-2026-137684 | A security flaw has been discovered in eosphoros-ai DB-GPT up to 0.8.3. This affects the function editor_sql_run of the file packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/editor/api_editor_v1.py of the component Editor SQL Run API. Performing a manipulation of the argument db_name results in authorization bypass. It is possible to initiate the attack remotely. The exploit has been released to the public and may be used for attacks. The pull request to fixCVSS 8.7CVE-2026-137992 | libexpat through 2.11.0 contains a denial of service vulnerability in defineAttribute() of lib/xmlparse.c that fails to detect duplicate non-ID #IMPLIED or #REQUIRED attribute declarations. Attackers can supply a crafted XML document with repeated ATTLIST declarations in an internal DTD subset to cause quadratic CPU consumption in storeAtts() during parsing.CVSS 8.5CVE-2026-137994 | Leo through 6.8.10 contains an insecure deserialization vulnerability that allows attackers to execute code by embedding pickled data in unknown XML attributes of .leo outlines. Attackers can place a pickle __reduce__ gadget in a or element attribute that resolveUa passes to pickle.loads, executing code with user privileges when the outline is opened.CVSS 7.0CVE-2026-137995 | FOG Project before 1.6.0.119 contains an information disclosure vulnerability that allows unauthenticated attackers to obtain host tokens from status/hostgetkey.php by supplying a host MAC address. Attackers can present the token to service/hostinfo.php to retrieve decrypted Active Directory join credentials and Windows product keys during deployment windows.CVSS 6.8CVE-2026-137996 | Zettlr before 4.11.0 fails to validate URI schemes in Markdown link targets, allowing attackers to launch arbitrary registered protocol handlers via Electron shell.openExternal without confirmation. Attackers can craft documents whose Ctrl/Cmd-clicked links use smb:// to leak NTLM credential hashes on Windows or invoke custom protocol handlers with attacker-controlled parameters.CVSS 8.5CVE-2026-137997 | HCIPy through 0.7.1 contains an insecure deserialization vulnerability that allows attackers to execute code by supplying crafted .pkl files to read_field, read_grid or read_mode_basis. Because hcipy/util/io.py selects pickle by file extension and calls pickle.load, a __reduce__ gadget in a pupil, apodizer, PSF or mode-basis file runs code with the user's privileges.CVSS 8.5CVE-2026-137998 | Detoxify 0.5.3 through 0.5.4 contains an insecure deserialization vulnerability in load_checkpoint that allows attackers to execute code by supplying a crafted checkpoint file. Attackers can embed a pickle __reduce__ gadget in a .ckpt file loaded via torch.load with weights_only=False to run code with the user's privileges.CVSS 8.5CVE-2026-137999 | JSONSchema2PoPo2 through 3.0.3 contains a code injection vulnerability that allows attackers to inject Python code by supplying JSON Schema default or format values that are written unescaped. Attackers can place a single quote in a string property default to break out of the literal in the generated __init__ signature, executing injected code when the generated module is imported.
Alle im Drawer
Intelligence View
⚡ tsecurity.de Intelligence

Swift Structs — Access Control 🔐

So far, every property and method we've added to our structs has been freely accessible from anywhere. But that's not always what you want. Sometimes you need…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Quelle & Fakten · 5 Min. Lesezeit
Quelle: dev.to
Rubrik: Sichere Programmierung

So far, every property and method we've added to our structs has been freely accessible from anywhere. But that's not always what you want. Sometimes you need to protect certain data from being changed in ways that could break your logic. That's exactly what access control is for. 🍥









The Problem Without Access Control



Let's say we're building a guild system for an anime RPG. A guild has a treasury, and members can deposit or withdraw gold — but only through proper channels:




struct GuildTreasury {
var gold = 0

mutating func deposit(amount: Int) {
gold += amount
}

mutating func withdraw(amount: Int) -> Bool {
if gold >= amount {
gold -= amount
return true
} else {
print("Not enough gold!")
return false
}
}
}






This looks good — we have proper deposit and withdraw methods that handle the logic. But here's the problem: gold is public by default, so nothing stops someone from doing this:




var fairyTail = GuildTreasury()
fairyTail.deposit(amount: 1000)
fairyTail.gold -= 9999 // 😱 Bypasses all our logic!






That completely skips our validation logic. The guild treasury could go deeply negative, and our program would behave in unpredictable ways.









private — Lock It Down



The fix is simple: mark gold as private. This tells Swift that gold can only be accessed inside the struct — not from outside:




struct GuildTreasury {
private var gold = 0

mutating func deposit(amount: Int) {
gold += amount
}

mutating func withdraw(amount: Int) -> Bool {
if gold >= amount {
gold -= amount
return true
} else {
print("Not enough gold!")
return false
}
}
}






Now this would fail to compile:




fairyTail.gold -= 9999 // ❌ 'gold' is inaccessible due to 'private' protection level






But this still works perfectly:




fairyTail.deposit(amount: 1000)   // ✅ uses our controlled method
fairyTail.withdraw(amount: 200) // ✅ uses our controlled method






Swift itself is now enforcing the rules — you can't accidentally bypass the logic even if you tried. 🎉




Important note: If you use private for one or more properties, you'll likely need to write a custom initializer, since Swift's auto-generated memberwise initializer won't be able to set private properties from outside the struct.










private(set) — Read Freely, Write Carefully



Sometimes you want the best of both worlds: anyone can read the value, but only the struct's own methods can change it.



That's exactly what private(set) does:




struct GuildTreasury {
private(set) var gold = 0

mutating func deposit(amount: Int) {
gold += amount
}

mutating func withdraw(amount: Int) -> Bool {
if gold >= amount {
gold -= amount
return true
} else {
print("Not enough gold!")
return false
}
}
}

var fairyTail = GuildTreasury()
fairyTail.deposit(amount: 1000)

print(fairyTail.gold) // ✅ Reading is fine — 1000
fairyTail.gold = 9999 // ❌ Writing directly is not allowed






This is perfect for our treasury — members of the guild can check how much gold is in the pot, but they can't just set it to whatever they want. Only the official deposit and withdraw methods can change it.









The Access Control Options



Swift gives us a few levels to choose from:




























Keyword What It Means
private Only accessible inside this struct (or class/enum)
fileprivate Accessible anywhere within the same Swift file
public Accessible from anywhere — inside or outside the module
private(set) Anyone can read, but only the struct can write


When you're learning and building apps, you'll mostly reach for private and private(set). The others become more relevant when you're building frameworks or larger multi-file projects.









Why Bother? You Could Just Not Break the Rules



You might be thinking: "I know not to bypass the withdrawal logic — why do I need Swift to enforce it?"



Here's the honest answer: you are not always the person who will touch this code.



Maybe you write the GuildTreasury struct today, and six months from now you're in a rush to fix a bug and accidentally write directly to gold without thinking. Or maybe a teammate who joined the project later doesn't know about the rules. Or maybe you're using a library someone else wrote and you need to follow their rules.



Access control is a way of saying: "here's the interface you're supposed to use — everything else is off limits." You're building a door and putting a lock on it, so that the only way in is through the proper entrance.



There's another benefit too: it reduces the surface area of your struct. If a struct has 15 properties and methods but 10 of them are private, anyone reading the code immediately knows: the 5 public ones are what I should be working with. The private ones are internal details, not something to worry about from the outside.









A Real-World Analogy



Think of a vending machine 🍥. You can see how many snacks are left through the glass (read access). You can press a button and pay to get one (controlled write through a method). But you can't open the front panel and take snacks directly — that access is locked.



private(set) is the glass panel. private is the locked door. The button is your deposit() or withdraw() method — the only approved way in.









Wrap Up
































Concept What It Means
Access control Controlling who can read or write a struct's properties and methods
private Only accessible inside the struct itself
private(set) Anyone can read, only the struct can write
public Accessible from anywhere
Why it matters Prevents accidental misuse, enforces rules, reduces surface area


Access control is one of those features that feels optional when you're just getting started, but becomes genuinely important the moment your code grows or gets shared with anyone else — including future you. 🌸






This article was written by me; AI was used to improve grammar and readability.

Information ergänzen Fachhinweis, Update, Korrektur oder Quelle zur Meldung beitragen
Gäste-Hinweise werden kurz redaktionell geprüft und danach hier angezeigt.

Community-Hinweise zur Meldung

0 freigegeben
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!
Informations-Bewertung:

💬 Community-Diskussion & Kommentare

🌐 Zum Hauptchat

Starte die Diskussion im Social-Chat Broadcast Stream oder reiche oben über „Information ergänzen“ einen Fachbeitrag ein.

Community Rating & Social Proof
⭐ Leser-Wertung
–
Ø / 5.0
Noch keine Leser-Bewertungen
War dieser Artikel hilfreich?
0
Jetzt Bewertung abgeben
Detail-Bewertung (optional)
Inhalt & Qualität
Quelle & Glaubwürdigkeit
Aktualität
Security Briefing Kostenlos · 1-Klick-Abmeldung

Intelligence Digest — kostenlos

Täglich die wichtigsten Security-News · jederzeit abbestellbar

Verwandte Story-Cluster & Quellen (Vektor-KI)

2 Cluster
2 Quellen
OpenAI counter-sues Apple over trade secret theft
AppleInsider News vor 16 Min.
1 weitere Quelle
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Swift Structs — Access Control 🔐

Thematisch verwandte Begriffe: Swift, Structs, Access, Control · 6 Treffer

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 ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
Widgets & Themen
Widgets werden geladen…
Nächster Beitrag