Asterisk - The Open Source Telephony Project  18.5.0
security_events_defs.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2012, Digium, Inc.
5  *
6  * Russell Bryant <[email protected]>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 /*!
20  * \file
21  *
22  * \brief Security Event Reporting Data Structures
23  *
24  * \author Russell Bryant <[email protected]>
25  */
26 
27 #ifndef __AST_SECURITY_EVENTS_DEFS_H__
28 #define __AST_SECURITY_EVENTS_DEFS_H__
29 
30 #include "asterisk/network.h"
31 #include "asterisk/netsock2.h"
32 
33 #if defined(__cplusplus) || defined(c_plusplus)
34 extern "C" {
35 #endif
36 
37 /*!
38  * \brief Security event types
39  */
41  /*!
42  * \brief Failed ACL
43  *
44  * This security event should be generated when an incoming request
45  * was made, but was denied due to configured IP address access control
46  * lists.
47  */
49  /*!
50  * \brief Invalid Account ID
51  *
52  * This event is used when an invalid account identifier is supplied
53  * during authentication. For example, if an invalid username is given,
54  * this event should be used.
55  */
57  /*!
58  * \brief Session limit reached
59  *
60  * A request has been denied because a configured session limit has been
61  * reached, such as a call limit.
62  */
64  /*!
65  * \brief Memory limit reached
66  *
67  * A request has been denied because a configured memory limit has been
68  * reached.
69  */
71  /*!
72  * \brief Load Average limit reached
73  *
74  * A request has been denied because a configured load average limit has been
75  * reached.
76  */
78  /*!
79  * \brief A request was made that we understand, but do not support
80  */
82  /*!
83  * \brief A request was made that is not allowed
84  */
86  /*!
87  * \brief The attempted authentication method is not allowed
88  */
90  /*!
91  * \brief Request received with bad formatting
92  */
94  /*!
95  * \brief FYI FWIW, Successful authentication has occurred
96  */
98  /*!
99  * \brief An unexpected source address was seen for a session in progress
100  */
102  /*!
103  * \brief An attempt at challenge/response authentication failed
104  */
106  /*!
107  * \brief An attempt at basic password authentication failed
108  */
110  /*!
111  * \brief Challenge was sent out, informational
112  */
114  /*!
115  * \brief An attempt to contact a peer on an invalid transport.
116  */
118  /*!
119  * \brief This _must_ stay at the end.
120  */
122 };
123 
124 /*!
125  * \brief the severity of a security event
126  *
127  * This is defined as a bit field to make it easy for consumers of the API to
128  * subscribe to any combination of the defined severity levels.
129  *
130  * XXX \todo Do we need any more levels here?
131  */
133  /*! \brief Informational event, not something that has gone wrong */
135  /*! \brief Something has gone wrong */
137 };
138 
139 #define AST_SEC_EVT(e) ((struct ast_security_event_common *) e)
140 
142  const struct ast_sockaddr *addr;
144 };
145 
146 /*!
147  * \brief Common structure elements
148  *
149  * This is the structure header for all event descriptor structures defined
150  * below. The contents of this structure are very important and must not
151  * change. Even though these structures are exposed via a public API, we have
152  * a version field that can be used to ensure ABI safety. If the event
153  * descriptors need to be changed or updated in the future, we can safely do
154  * so and can detect ABI changes at runtime.
155  */
157  /*! \brief The security event sub-type */
158  enum ast_security_event_type event_type;
159  /*! \brief security event version */
160  uint32_t version;
161  /*!
162  * \brief Service that generated the event
163  * \note Always required
164  *
165  * Examples: "SIP", "AMI"
166  */
167  const char *service;
168  /*!
169  * \brief Module, Normally the AST_MODULE define
170  * \note Always optional
171  */
172  const char *module;
173  /*!
174  * \brief Account ID, specific to the service type
175  * \note optional/required, depending on event type
176  */
177  const char *account_id;
178  /*!
179  * \brief Session ID, specific to the service type
180  * \note Always required
181  */
182  const char *session_id;
183  /*!
184  * \brief Session timeval, when the session started
185  * \note Always optional
186  */
187  const struct timeval *session_tv;
188  /*!
189  * \brief Local address the request came in on
190  * \note Always required
191  */
192  struct ast_security_event_ip_addr local_addr;
193  /*!
194  * \brief Remote address the request came from
195  * \note Always required
196  */
197  struct ast_security_event_ip_addr remote_addr;
198 };
199 
200 /*!
201  * \brief Checking against an IP access control list failed
202  */
204  /*!
205  * \brief Event descriptor version
206  * \note This _must_ be changed if this event descriptor is changed.
207  */
208  #define AST_SECURITY_EVENT_FAILED_ACL_VERSION 1
209  /*!
210  * \brief Common security event descriptor elements
211  * \note Account ID required
212  */
214  /*!
215  * \brief ACL name, identifies which ACL was hit
216  * \note optional
217  */
218  const char *acl_name;
219 };
220 
221 /*!
222  * \brief Invalid account ID specified (invalid username, for example)
223  */
225  /*!
226  * \brief Event descriptor version
227  * \note This _must_ be changed if this event descriptor is changed.
228  */
229  #define AST_SECURITY_EVENT_INVAL_ACCT_ID_VERSION 1
230  /*!
231  * \brief Common security event descriptor elements
232  * \note Account ID required
233  */
235 };
236 
237 /*!
238  * \brief Request denied because of a session limit
239  */
241  /*!
242  * \brief Event descriptor version
243  * \note This _must_ be changed if this event descriptor is changed.
244  */
245  #define AST_SECURITY_EVENT_SESSION_LIMIT_VERSION 1
246  /*!
247  * \brief Common security event descriptor elements
248  * \note Account ID required
249  */
251 };
252 
253 /*!
254  * \brief Request denied because of a memory limit
255  */
257  /*!
258  * \brief Event descriptor version
259  * \note This _must_ be changed if this event descriptor is changed.
260  */
261  #define AST_SECURITY_EVENT_MEM_LIMIT_VERSION 1
262  /*!
263  * \brief Common security event descriptor elements
264  * \note Account ID required
265  */
267 };
268 
269 /*!
270  * \brief Request denied because of a load average limit
271  */
273  /*!
274  * \brief Event descriptor version
275  * \note This _must_ be changed if this event descriptor is changed.
276  */
277  #define AST_SECURITY_EVENT_LOAD_AVG_VERSION 1
278  /*!
279  * \brief Common security event descriptor elements
280  * \note Account ID required
281  */
283 };
284 
285 /*!
286  * \brief Request denied because we don't support it
287  */
289  /*!
290  * \brief Event descriptor version
291  * \note This _must_ be changed if this event descriptor is changed.
292  */
293  #define AST_SECURITY_EVENT_REQ_NO_SUPPORT_VERSION 1
294  /*!
295  * \brief Common security event descriptor elements
296  * \note Account ID required
297  */
299  /*!
300  * \brief Request type that was made
301  * \note required
302  */
303  const char *request_type;
304 };
305 
306 /*!
307  * \brief Request denied because it's not allowed
308  */
310  /*!
311  * \brief Event descriptor version
312  * \note This _must_ be changed if this event descriptor is changed.
313  */
314  #define AST_SECURITY_EVENT_REQ_NOT_ALLOWED_VERSION 1
315  /*!
316  * \brief Common security event descriptor elements
317  * \note Account ID required
318  */
320  /*!
321  * \brief Request type that was made
322  * \note required
323  */
324  const char *request_type;
325  /*!
326  * \brief Request type that was made
327  * \note optional
328  */
329  const char *request_params;
330 };
331 
332 /*!
333  * \brief Auth method used not allowed
334  */
336  /*!
337  * \brief Event descriptor version
338  * \note This _must_ be changed if this event descriptor is changed.
339  */
340  #define AST_SECURITY_EVENT_AUTH_METHOD_NOT_ALLOWED_VERSION 1
341  /*!
342  * \brief Common security event descriptor elements
343  * \note Account ID required
344  */
346  /*!
347  * \brief Auth method attempted
348  * \note required
349  */
350  const char *auth_method;
351 };
352 
353 /*!
354  * \brief Invalid formatting of request
355  */
357  /*!
358  * \brief Event descriptor version
359  * \note This _must_ be changed if this event descriptor is changed.
360  */
361  #define AST_SECURITY_EVENT_REQ_BAD_FORMAT_VERSION 1
362  /*!
363  * \brief Common security event descriptor elements
364  * \note Account ID optional
365  */
367  /*!
368  * \brief Request type that was made
369  * \note required
370  */
371  const char *request_type;
372  /*!
373  * \brief Request type that was made
374  * \note optional
375  */
376  const char *request_params;
377 };
378 
379 /*!
380  * \brief Successful authentication
381  */
383  /*!
384  * \brief Event descriptor version
385  * \note This _must_ be changed if this event descriptor is changed.
386  */
387  #define AST_SECURITY_EVENT_SUCCESSFUL_AUTH_VERSION 1
388  /*!
389  * \brief Common security event descriptor elements
390  * \note Account ID required
391  */
393  /*!
394  * \brief Using password - if a password was used or not
395  * \note required, 0 = no, 1 = yes
396  */
397  uint32_t using_password;
398 };
399 
400 /*!
401  * \brief Unexpected source address for a session in progress
402  */
404  /*!
405  * \brief Event descriptor version
406  * \note This _must_ be changed if this event descriptor is changed.
407  */
408  #define AST_SECURITY_EVENT_UNEXPECTED_ADDR_VERSION 2
409  /*!
410  * \brief Common security event descriptor elements
411  * \note Account ID required
412  */
414  /*!
415  * \brief Expected remote address
416  * \note required
417  */
418  struct ast_security_event_ip_addr expected_addr;
419 };
420 
421 /*!
422  * \brief An attempt at challenge/response auth failed
423  */
425  /*!
426  * \brief Event descriptor version
427  * \note This _must_ be changed if this event descriptor is changed.
428  */
429  #define AST_SECURITY_EVENT_CHAL_RESP_FAILED_VERSION 1
430  /*!
431  * \brief Common security event descriptor elements
432  * \note Account ID required
433  */
435  /*!
436  * \brief Challenge provided
437  * \note required
438  */
439  const char *challenge;
440  /*!
441  * \brief Response received
442  * \note required
443  */
444  const char *response;
445  /*!
446  * \brief Response expected to be received
447  * \note required
448  */
449  const char *expected_response;
450 };
451 
452 /*!
453  * \brief An attempt at basic password auth failed
454  */
456  /*!
457  * \brief Event descriptor version
458  * \note This _must_ be changed if this event descriptor is changed.
459  */
460  #define AST_SECURITY_EVENT_INVAL_PASSWORD_VERSION 2
461  /*!
462  * \brief Common security event descriptor elements
463  * \note Account ID required
464  */
466  /*!
467  * \brief Challenge provided
468  * \note required
469  */
470  const char *challenge;
471  /*!
472  * \brief Challenge received
473  * \note required
474  */
475  const char *received_challenge;
476  /*!
477  * \brief Hash received
478  * \note required
479  */
480  const char *received_hash;
481 };
482 
483 /*!
484  * \brief A challenge was sent out
485  */
487  /*!
488  * \brief Event descriptor version
489  * \note This _must_ be changed if this event descriptor is changed.
490  */
491  #define AST_SECURITY_EVENT_CHAL_SENT_VERSION 1
492  /*!
493  * \brief Common security event descriptor elements
494  * \note Account ID required
495  */
497  /*!
498  * \brief Challenge sent
499  * \note required
500  */
501  const char *challenge;
502 };
503 
504 /*!
505  * \brief Attempt to contact peer on invalid transport
506  */
508  /*!
509  * \brief Event descriptor version
510  * \note This _must_ be changed if this event descriptor is changed.
511  */
512  #define AST_SECURITY_EVENT_INVAL_TRANSPORT_VERSION 1
513  /*!
514  * \brief Common security event descriptor elements
515  * \note Account ID required
516  */
518  /*!
519  * \brief Attempted transport
520  * \note required
521  */
522  const char *transport;
523 };
524 
525 #if defined(__cplusplus) || defined(c_plusplus)
526 }
527 #endif
528 
529 #endif /* __AST_SECURITY_EVENTS_DEFS_H__ */
uint32_t using_password
Using password - if a password was used or not.
ast_security_event_severity
the severity of a security event
An attempt at basic password authentication failed.
ast_security_event_type
Security event types.
const char * auth_method
Auth method attempted.
FYI FWIW, Successful authentication has occurred.
const char * expected_response
Response expected to be received.
const char * challenge
Challenge provided.
An attempt at challenge/response auth failed.
const char * transport
Attempted transport.
ast_transport
Definition: netsock2.h:59
const char * service
Service that generated the event.
const char * account_id
Account ID, specific to the service type.
const char * module
Module, Normally the AST_MODULE define.
Request denied because we don&#39;t support it.
Checking against an IP access control list failed.
const char * challenge
Challenge provided.
const char * request_type
Request type that was made.
The attempted authentication method is not allowed.
A challenge was sent out.
const char * response
Response received.
Unexpected source address for a session in progress.
Common structure elements.
A request was made that is not allowed.
An unexpected source address was seen for a session in progress.
const char * received_hash
Hash received.
uint32_t version
security event version
Socket address structure.
Definition: netsock2.h:97
Informational event, not something that has gone wrong.
An attempt at basic password auth failed.
const char * request_type
Request type that was made.
Request received with bad formatting.
Request denied because of a session limit.
const char * session_id
Session ID, specific to the service type.
const char * request_params
Request type that was made.
Challenge was sent out, informational.
Network socket handling.
const struct ast_sockaddr * addr
Wrapper for network related headers, masking differences between various operating systems...
Attempt to contact peer on invalid transport.
const char * received_challenge
Challenge received.
Request denied because of a memory limit.
Load Average limit reached.
Request denied because of a load average limit.
An attempt at challenge/response authentication failed.
const char * acl_name
ACL name, identifies which ACL was hit.
This must stay at the end.
Invalid account ID specified (invalid username, for example)
const char * challenge
Challenge sent.
Invalid formatting of request.
const char * request_params
Request type that was made.
const struct timeval * session_tv
Session timeval, when the session started.
Request denied because it&#39;s not allowed.
const char * request_type
Request type that was made.
An attempt to contact a peer on an invalid transport.
A request was made that we understand, but do not support.