mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
Addresses 14 findings from the security audit across all severity levels: CRITICAL: - C-1: Add user blocking system (migration, DB queries, REST API, WS DM send check) to prevent harassment via unconsented DMs - C-2: Remove server version from unauthenticated /health and /info endpoints to prevent fingerprinting HIGH: - H-1: Remove dangerous-settings feature from tauri-plugin-http - H-3: Default allowSelfSigned to false in API client (was hardcoded true) - H-4: Cap invite expiration to 30 days (720 hours) - H-5: Add 256KB message size limit to LiveKit WS proxy (prevents OOM) - H-6: Cap concurrent sessions to 25 per user (evicts oldest on overflow) - H-8: Restrict /diagnostics/connectivity to ADMINISTRATOR role MEDIUM: - M-2: Deny access to legacy NULL-uploader unlinked attachments - M-4: Log warnings on TOTP plaintext decryption fallback paths - M-8: Remove acceptInvalidCerts from OG preview fetches - M-10: Expand file upload blocklist (Java .class, OLE2, WASM, .lnk) - M-12: Add LIMIT to ListInvites (200) and ListMembers (1000) - M-14: Add CHECK constraint trigger on channels.type (text/voice/dm) https://claude.ai/code/session_01KKo3RwjdmcNzkgXNfUkgNT
32 lines
866 B
Go
32 lines
866 B
Go
package db
|
|
|
|
import "fmt"
|
|
|
|
// ListInvites returns invites ordered by creation time descending.
|
|
// M-12: Limited to 200 rows to prevent unbounded result sets.
|
|
func (d *DB) ListInvites() ([]*Invite, error) {
|
|
rows, err := d.sqlDB.Query(
|
|
`SELECT id, code, created_by, max_uses, use_count, expires_at, revoked, created_at
|
|
FROM invites ORDER BY created_at DESC LIMIT 200`,
|
|
)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("ListInvites: %w", err)
|
|
}
|
|
defer rows.Close() //nolint:errcheck
|
|
|
|
var invites []*Invite
|
|
for rows.Next() {
|
|
inv := &Invite{}
|
|
var revoked int
|
|
if err := rows.Scan(
|
|
&inv.ID, &inv.Code, &inv.CreatedBy, &inv.MaxUses,
|
|
&inv.Uses, &inv.ExpiresAt, &revoked, &inv.CreatedAt,
|
|
); err != nil {
|
|
return nil, fmt.Errorf("ListInvites scan: %w", err)
|
|
}
|
|
inv.Revoked = revoked != 0
|
|
invites = append(invites, inv)
|
|
}
|
|
return invites, rows.Err()
|
|
}
|